It is not possible to move a file from public://mydirectory/myfile.txt to private://mydirectory/myfile.txt. In case private://mydirectory is not a directory.
File entity use file_move() [1] for this step, but the problem File entity does not check if the directory exists in the destination file system.
[1]http://drupalcode.org/project/file_entity.git/blob/13fa2b0bcb73d066b996b...
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 2264145-create-dir-before-moving-files-20.patch | 851 bytes | joseph.olstad |
| #13 | 2264145-create-dir-before-moving-files-13.patch | 851 bytes | thepanz |
| #11 | 2264145-create-dir-before-moving-files.patch | 954 bytes | johan.gant |
| #8 | file_entity-2264145.patch | 831 bytes | ParisLiakos |
Comments
Comment #1
tobiasbComment #2
sheldonkreger commentedIt would be nice to have a method to switch file schemes in the UI. I've had content owners who set up Webforms with file attachment fields, only to realize later that the uploaded attachments are visible publicly if the URL is known. In such cases, it makes sense to have certain roles allowed to switch the scheme of a file via the UI.
It also makes sense to be able to do this programatically, obviously.
Let me take a look and see how much work this is to implement.
Comment #3
dave reidScheme selection is already available in the UI, you just need to have multiple writeable file systems in order for it to be visible.
Comment #4
sheldonkreger commentedCorrect me if I'm wrong, but I believe the scheme selection is available when files are uploaded, but there is an option to disable it as well. Having it disabled makes sense for most users due to confusion (do I choose public or private?). What I'd like to build out is another option with its own permission to switch the scheme on existing files. That way only users who are trained can make changes and other users don't get the option during upload.
Comment #5
dave reidNo, I'm talking about a UI that already exists on the file edit form as of today in 7.x-2.x.
Comment #6
sheldonkreger commentedCool! I'll pull it down and check it out. Where was that committed?
Comment #7
devin carlson commentedThe ability to select stream wrappers during file upload was added in #1580820: Provide interfaces for selecting stream wrappers during file upload and converting files between stream wrappers.
Comment #8
ParisLiakos commentedthat probably needs a test, but here is a quick patch
Comment #11
johan.gant commentedHad the same problem, but in the past it's seemed intermittent due to the fact most files already had folders on disk. I've re-rolled the patch in https://www.drupal.org/node/2264145#comment-9894683 against 2.x-dev, attaching.
Comment #12
anybodyI can confirm the patch from #11 works great and solves these problems.
Ready to be commited.
Comment #13
thepanz commentedUpdated patch:
- keep original variable names
- avoid Strict warnings for "variables passed by reference"
Comment #14
chalk commentedConfirm that #13 works! My solution to fix this bug was the same.
Comment #15
thepanz commentedThanks Chalk to test the patch.
Any plans to merge this patch?
Comment #16
euk commentedThe patch #13 worked for me as well.
Comment #17
danielvezaHave been using #13 on production sites with no issues. Any plans for this from maintainers?
Comment #18
joseph.olstadTo get this committed very soon, if I don't get to it first, please reroll this patch and upload , set the issue to 'Needs review' so as to wake up the testbot and trigger the simpletests. my preference is to test against 5.6, 5.5, 5.4, 5.3, 7.0 and 7.1.
Comment #19
danielvezaThanks mate. If I get some spare time over the weekend I'll do that.
Comment #20
joseph.olstadrerolled verbatim , same patch as #13 , but needed to be re-uploaded for re-testing.
Comment #22
joseph.olstadfixed in 7.x-2.x-dev