I'm unable to upload the image files into private folder path:

How to reproduce:
1. My folder structure is:
/var/www/html/projects/private
/var/www/html/projects/lightning-drupal

2. In my settings.php i have set the private path to /var/www/html/projects/private
3. In Configuration > Media > File System I have selected the option "Private local files served by Drupal."
4. In "landing page" content type I have created the image field and in "Field Setting" selected "Private Files" option under "Upload Destination"
5. In Admin > Configuration > CONTENT AUTHORING > Entity Browsers > image_browser > Widgets > Selected UPLOAD widget and added "private://" in upload location.
6. Given 777 permission to private folder (first tried with 775)

Now when I'm creating the new content into Landing Page content type and uploading the image through image media widget, first image is getting uploaded into /sites/default/files/styles/medium but it is not moving the file to private folder path and also not creating the thumbnail image into private path and showing broken image "/system/files/styles/thumbnail/private/2017-04/image.jpg?itok=_KrvV3fr"

Comments

rajivmandve created an issue. See original summary.

balsama’s picture

Priority: Critical » Normal

It looks like you've done everything correct, including adding the additional upload widget. I followed your exact steps, except I additionally deleted the existing File Upload widget from the EB so I could be certain that I was uploading the image through the correct widget and my private file path is "../private".

The only problem I was able to reproduce is that the thumbnail returns a 403 the first time you try to load it. Subsequent requests for it work fine. Everything else worked as expected. Files were uploaded to the ../private directory as expected and image styles were created in ../private/styles/STYLE/private/DATE/.

The only thing that jumps out is that your private file directory appears to possibly be web serve-able. That might cause some unexpected behavior (and would obviously defeat the purpose of private files :))

I'm moving the priority back down until we can reproduce this. As it stands, we're having trouble initially loading the thumbnail, and I doubt that's a Lightning issue.

rajivmandve’s picture

Yes in my case system is not at all generating thumbnail and medium folders inside ../private/styles/ (while I have given -R 777 permissions to ../private folder), hence thumbnail and medium images are not getting uploaded.

I have installed lightning on my local machine and tried to upload the image file but still I'm facing the same issue on my local machine as well. No STYLE folders have been created and no files are uploading.

If you suggest me the fix for it that would be great help.

johnkennedy’s picture

It might be helpful to take the infrastructure out of the equation. Have you tried this on DrupalVM?
http://docs.drupalvm.com/en/latest/deployment/composer-package/

rajivmandve’s picture

My actual project is created using composer and deployed on Acquia.

meezaan’s picture

HI John, Adam,

Just FYI - I haven't had time to dig into this in more detail, but downgrading to lightning 2.0.6 from 2.1.0 solves the problem.

So a module update or the core update from 8.2.8 to 8.3.1 is theoretically to blame for this.

Where the issue is originating, I don't know yet.

phenaproxima’s picture

Component: Code » Media

Re-classifying as a Media issue.

phenaproxima’s picture

Status: Active » Closed (cannot reproduce)

I tried this on Lightning 2.14 and was not able to reproduce it.

I followed the exact steps from the issue summary (thanks for the crystal-clear instructions, @rajivmandve!) and saw precisely the behavior that @balsama described in #2: the file is uploaded to the correct location, but the thumbnail is initially not served correctly by Drupal.

At that point, I enabled Xdebug and tried tracing into the problem, and discovered that there is some weirdness going on in core (access to the derived style is denied because image_file_download() has no opinion about it and even then it's because the URI that is passed to the function does not start with styles/ -- which somehow changes when the page is refreshed). I'm not sure what's going on, but the broken code is definitely not part of Lightning. Nor has Lightning, to my knowledge, ever influenced the file access logic in any way.

Therefore, in addition to the fact that neither @balsama or I can reproduce the behavior described in the issue summary, I'm not convinced that this is in scope for us to fix. So I'm closing this issue, but feel free to re-open it if it seems appropriate.

meezaan’s picture

@phenaproxima FYI - I should have posted an update on this.

This is almost certainly an issue on core. It has to do with the fact that a derivative gets treated as an orphan - particularly if it is related to an older revision. There were at least six issues in D8 core on June 12 and 13 (when i was researching) related to private files and derivatives (I'll post links when i can dig them up again).

It's safe to say that private files are not production ready in D8.