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...

Comments

tobiasb’s picture

Issue summary: View changes
sheldonkreger’s picture

It 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.

dave reid’s picture

Scheme selection is already available in the UI, you just need to have multiple writeable file systems in order for it to be visible.

sheldonkreger’s picture

Correct 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.

dave reid’s picture

No, I'm talking about a UI that already exists on the file edit form as of today in 7.x-2.x.

sheldonkreger’s picture

Cool! I'll pull it down and check it out. Where was that committed?

devin carlson’s picture

ParisLiakos’s picture

Status: Active » Needs review
StatusFileSize
new831 bytes

that probably needs a test, but here is a quick patch

Status: Needs review » Needs work

The last submitted patch, 8: file_entity-2264145.patch, failed testing.

johan.gant’s picture

Status: Needs work » Needs review
StatusFileSize
new954 bytes

Had 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.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm the patch from #11 works great and solves these problems.
Ready to be commited.

thepanz’s picture

Updated patch:
- keep original variable names
- avoid Strict warnings for "variables passed by reference"

chalk’s picture

Confirm that #13 works! My solution to fix this bug was the same.

thepanz’s picture

Thanks Chalk to test the patch.

Any plans to merge this patch?

euk’s picture

The patch #13 worked for me as well.

danielveza’s picture

Have been using #13 on production sites with no issues. Any plans for this from maintainers?

joseph.olstad’s picture

To 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.

danielveza’s picture

Thanks mate. If I get some spare time over the weekend I'll do that.

joseph.olstad’s picture

rerolled verbatim , same patch as #13 , but needed to be re-uploaded for re-testing.

  • johan.gant authored 39eaae8 on 7.x-2.x
    Issue #2264145 by thePanz, joseph.olstad, ParisLiakos, johan.gant:...
joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

fixed in 7.x-2.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.