drupal_amazons3 icon indicating copy to clipboard operation
drupal_amazons3 copied to clipboard

Problems with temporary files

Open ergonlogic opened this issue 9 years ago • 4 comments

Hi, first off, thanks again for the work on this module. It's working beautifully for us, in all but a couple use-cases. Importing images via feeds results in the following failures:

The specified file temporary://filenCiAjj could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.

It is coming from file_unmanaged_copy(), and as far as I can tell, this appears to be related to the use of temporary files. While this warning doesn't tell us much about the destination in question, dropping in some debug statements shows that it has a $destination parameter set to s3://image_title.jpeg. As a result, file_prepare_directory() is failing.

ergonlogic avatar May 26 '15 20:05 ergonlogic

Can you check to see if feeds is calling file_stream_wrapper_uri_normalize()? If not, and it's creating a URL without a bucket, we never get a chance to set the default bucket on the URI. You might be able to work around it by configuring feeds to include the bucket in a directory path token.

For image styles, we use file_unmanaged_copy() to copy generated styles from a temporary directory to S3, so I'm pretty sure that works in at least the basic case.

deviantintegral avatar May 26 '15 21:05 deviantintegral

I think the issue might be stemming from here, where Feeds appears indeed not to call file_stream_wrapper_uri_normalize().

Bear with me, as I'm not very familiar with this code... Seeing as how you've implemented StreamWrapper::realpath() to always return FALSE, we end up in the else clause in FeedsEnclosure::getFile(). As a result we end up calling file_save_data(), which calls file_unmanaged_save_data(), then file_unmanaged_move() which finally calls file_unmanaged_copy(), where we throw this error.

ergonlogic avatar May 26 '15 21:05 ergonlogic

Calling file_stream_wrapper_uri_normalize() on $destination doesn't appear to do anything... is the bucket name supposed to be injected at some point?

ergonlogic avatar May 26 '15 21:05 ergonlogic

Oh right... so I've documented that patch as being required for Media module. But, it's entirely possible it's needed for other modules. Perhaps I should make that patch required, even though core image module doesn't need it.

https://www.drupal.org/node/2479523#comment-9873165

Which lets us implement: https://github.com/justafish/drupal_amazons3/blob/7.x-2.x/amazons3.module#L437

In feeds case though, I'm not sure. I feel like the issue is in whatever is setting the value on the element might be where we need to normalize the URL.

deviantintegral avatar May 27 '15 20:05 deviantintegral