-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssetHelper fopen and assetDownloadCurl additional HTTP headers #1538
Comments
Looks like it’s not documented (on it), but Feed Me supports setting a <?php
return [
'*' => [
'clientOptions' => [
'headers' => [
'User-Agent' => '...',
],
],
],
]; |
Hi Brandon. Thank you for looking into it. Funnily enough I noted this a while back #1441. However unfortunately in this case specifically for asset importing, this wouldn't apply I don't think. The use of clientOptions would apply on the main Feed URL request, but the AssetHelper class makes a request for the image URL from a seperate client i.e. fopen or curl if using the config setting to set the usage of curl. However, neither allow for adding or changing headers sent with this request. I ended up writing my own asset importing logic for the CDN image paths where I can control the request headers. Providing I can get the images into asset storage before the feed runs, I can then leverage the asset find query performed on the filename to allow Feed Me to match the asset and add it to the element as needed. It would be nice for consistency if the AssetHelper class used Guzzle which could provide extendibility, I don't know if there's a reason for using fopen/raw curl, perhaps legacy? |
I raised a PR to support asset downloads via Guzzle too. |
Thank you @i-just. This will be most useful if merged! |
Feed Me 5.9.0 and 6.6.0 are out with this fix! https://github.com/craftcms/feed-me/releases/tag/5.9.0 |
Description
I have a feed which provides CDN image paths, we have these linked to an asset field to import but the origin server throws a 403 Forbidden error on requests for the image which are lacking a User-Agent value. I confirmed it locally by running wget/curl with and without.
Example error
The setting assetDownloadCurl exists, but the issue is there is no way to set additional curl options on the asset download request
fopen can also provide HTTP headers as well, but this is currently not possible to define without forking or using FeedMe events to fetch the image with a client that provides the required headers.
Additional info
The text was updated successfully, but these errors were encountered: