I'm trying to use a private file system on Drupal 8.4.2 (standard profile with mostly default values), and noticed that files from fields that use a private file folder can't be uploaded:

Error: "The upload directory private://2017-12 for the file field field_private_attachment could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled."

My private file folder has rwxrws--- permissions, and the status report shows no further issues.

So I did some light digging and found out that the field was configured to use the default "[date:custom:Y]-[date:custom:m]" as file directory.

If I use an empty or static value instead, the files are uploaded.

But with images this only works if no image style is selected, or else this error pops up in the log:

Unable to generate the derived image located at private://styles/large/private/filename.png.

Is this a bug, or did I miss something else?

Comments

seirerman created an issue. See original summary.

seirerman’s picture

Issue summary: View changes
cilefen’s picture

Berdir’s picture

Status: Active » Postponed (maintainer needs more info)

Can't reproduce, creating folders works fine here for an an image field using private files.

Also not related to the default value issue because it also can't create image style directories.

Check the logs, sometimes Drupal logs there if it can't create directories, might be some advanced permission problem.

seirerman’s picture

Status: Postponed (maintainer needs more info) » Active

I think I can reproduce this now, and the issue might be related to the language module and setting a second language besides english as default:

  • Install Drupal 8.4
  • sites/default/settings.php: Define private folder ($settings['file_private_path'] = 'sites/default/files/private';)
  • Clear caches
  • Check Drupal file system settings if private folder is recognized
  • Set image field for articles to private
  • Create new article (Saving isn't necessary)
  • Upload image to article (Preview thumbnail loads, everything looks fine)
  • Install language module
  • Create new article
  • Upload image to article (Preview thumbnail loads, everything looks still fine)
  • Add a second language
  • Create new article
  • Upload image to article (Preview thumbnail loads, everything looks still fine)
  • Make second language the default language
  • Create new article
  • Upload image to article (Preview thumbnail fails to load)
  • Check recent log messages: "page not found - /de/system/files/styles/thumbnail/private/2017-12/filename.png?itok=xIbSidtd"

Would you mind giving it a try?

Berdir’s picture

Ah, multilingual, of course.

I think this might be a duplicate of some existing issues in that case, have a look at #2797639: For multi language private files FileDownloadController is used for the ImageStyle instead of ImageStyleDownloadController

seirerman’s picture

Thanks!!1

The patch from #2797639 fixed this, it seems.

cilefen’s picture

Status: Active » Closed (duplicate)

good!