#755556: Support saving local files in filefields added the ability to save local files to a FileField, and as a security measure, a check with file_directory_path() was added.

However, if an importer wants to download a file and save it directly to a FileField, it makes more sense to save it to a temporary directory instead of persistent storage like the files directory.

The use case for this is e-mail attachments with Mailhandler 2.x: there are no remote URLs for attachments, and the file data exists within the message itself. Rather than saving e-mail attachments into a public folder without context, it makes more sense to be able to save a file in temp, add it to a FileField (which may benefit from permissions), and delete the temporary file.

Attached is a patch that checks file_directory_temp() in addition to file_directory_path().

#2 feeds-926616.patch947 bytesMark Trapp
feeds-getfile_temp.patch948 bytesMark Trapp
Members fund testing for the Drupal project. Drupal Association Learn more


alex_b’s picture

Status: Needs review » Reviewed & tested by the community

This looks good. Will need porting to Drupal 7.

Mark Trapp’s picture

947 bytes

One too many parentheses: attached is a working patch.

I'll look at providing a port for D7 this weekend; I'm pretty sure it's simple and straightforward, but I don't have anything on hand to test it with.

alex_b’s picture

Cool. Should be straightforward, yes.

There is a new release of Feeds Test Site for Drupal 7 which should get you started fast on D7: http://drupal.org/node/927742 (I just created the release, give it a little to publish).

Mark Trapp’s picture

I finally got around to testing this in Drupal 7, and I wish I did it sooner: this is a non-issue in Feeds 7.x-2.x, as it does not place a constraint requiring the file to be in the public files directory.

As such, only Feeds 6.x-1.x-dev needs to be patched: the patch in #2 is still valid.

Note: #927014: Provide e-mail attachments as FeedEnclosure objects to support FileField mappings for Mailhandler 6.x-2.x depends on this patch.

alex_b’s picture

Status: Reviewed & tested by the community » Fixed
Mark Trapp’s picture

Sweet, thanks!

Status: Fixed » Closed (fixed)

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