I have a migrate script routine that sets file references for several nodes. I was finding that the paths to these files were not matching up with the path settings that I had configured on the file field. It turned out to be an issue with the call to file_prepare_directory(). In my case, the destination directory had already existed, but I was receiving this error:

[notice] The file public://private/press_release/additional/5-steps-cert-dev-exam_0_0.pdf could not be moved to the destination of public://private/press_release/additional/5-steps-cert-dev-exam_0_0.pdf. Ensure your permissions are set correctly.

Note: The log message doesn't display the destination directory -- a patch has been submitted for that here: Logger does not record new file destination on failed move

I don't think this is an issue with my system's file permissions, because files were being placed in the expected directory when I was attaching files manually (via the node form).

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rvillan created an issue. See original summary.

rvillan’s picture

nwom’s picture

Status: Active » Needs review
voleger’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
Related issues: +#3403246: Prevent crashing on file move when file is not found, fix schema bugs

Needs MR

immaculatexavier made their first commit to this issue’s fork.

immaculatexavier’s picture

Issue tags: +Singapore2024
immaculatexavier’s picture

Status: Needs work » Needs review

voleger’s picture

Status: Needs review » Needs work

Tests are not passed.