I am importing a feed with dynamic enclosures like:
http://productimages.wehkamp.nl/is/image/Wehkamp/?src=Wehkamp%2F415538_pb_01
This type of URL leads to errors during getFile($destination) in FeedsParser.inc:
File temporary://filA163.tmp could not be copied, because the destination directory is not configured correctly.
The reason is that my URL has no basename($filename)
Actually, once you fetch that image, the actual filename dynamically becomes productimages.wehkamp.nl.jpg in the example above. But basename() does not derive that from the URL. It doesn't do the remote call to see what is the actual returned filename.
Comments
Comment #1
marcvangendSubscribe.
I have worked around this problem before by placing a custom php script (imagewrapper.php) on my server that accepts a clean url (just like Drupal's index.php does), retrieves the image with CURL and returns it. This way you end up with filenames exactly like you want them, but the downside is the extra request in the chain.
This is what my imagewrapper.php looks like:
Note that I do not really recommend this approach, it's only a workaround.
Comment #2
riho commentedI had the same problem, so I created a patch for it. It uses the file name it finds from the header or falls back to the basename.
Comment #3
stewart.adam commentedRebased to latest git (7.x-2.x I reworked riho's patch a little bit as http_request_get() returns its header array using lowercase keys, so checking against
...->headers['Content-Dispotion']would fail.I've also added a secondary regex to support the case where the server doesn't properly quote the filename, such as some IIS servers. branch).
Comment #5
stewart.adam commentedAttached patch checks for the presence of the Content-Disposition header to prevent PHP notices... This one should pass the test bot.
Comment #6
thatpixguy commentedI need this feature and just made a patch of my own, but before posting it I found this issue request :)
The latest submitted patch seems more complete than my solution, so I won't add noise with mine.
pix
Comment #7
twistor commentedhmm yes.
Comment #8
kenorb commentedConverted against the latest dev.
Comment #9
megachriz#2510788: Remove query string from path in FeedsEnclosure. looks related, adding for reference.
Comment #10
kenorb commentedExpanded patch and attached below.
Comment #11
kenorb commentedCombined #8 patch with #2611014-4: Feeds doesn't import remote images which have no proper extension (such as ASP) as they're fairly related.
Comment #12
kenorb commentedAs #11, but with small fix:
As $this->allowedExtensions isn't an array, but string.
Tested Feed import and it works fine.
Comment #13
c.dan commentedDownloaded latest dev version + applied patch #12. Doesn't save the file.
My links are in this format:
http://picscdn.redblue.de/doi/pixelboxx-mss-62050889/fee_786_587_png/101-Dalmatinerna-Barn-DVDComment #14
fougere commentedSmall modification to the previous patch.
The allowed extension check was done before retrieving the filename in the http headers.
So it fails unless your url already ends with the correct extension (like in comment #13).
Comment #16
fougere commentedUnit test fix. The watchdog message for invalid extensions was not the same as before.
Comment #17
AlexKirstenZA commentedAdjusted the patch submitted in comment #16, in order to allow NewsCred images to be imported into image fields.
Comment #18
megachrizThe last patch seems to undo a lot of other changes made in other issues.
Comment #19
bluegeek9 commentedUnfortunately, Drupal 7 is End of Life and no longer supported. We strongly encourage you to upgrade to a supported version of Drupal.