Images with Query String Breaks Fetch...?
Hi Cloudinary Support
I'm working on a project where I'm referencing images from Instagram, via a JSON file.
The issue is that I can't fetch the image, it seems, because they add a query to the end of the URL for the image:
https://scontent.cdninstagram.com/vp/be2c65e9fb414dd04d484bb8d7f50665/5CB5AFBE/t51.2885-15/sh0.08/e35/s640x640/41518336_1880030458786298_577146229815363603_n.jpg?_nc_ht=scontent.cdninstagram.com
It may be another reason why the fetch on the URL isn't working, but I have feeling that because the URL isn't ending in a file extension the Cloudinary fetch is failing, so I can't use the magical cropping and manipulation tricks you provide...
Do you have any thoughts/insights? Is there a way to force the API to render the image even if it doesn't end in a file extension? Taking the query off the URL sadly breaks the image reference altogether...
Many thanks!
-
Hi David,
Whenever there is a '?' in the URL it needs to be escaped. So you can fetch the photo by doing this:
https://res.cloudinary.com/<cloudname>/image/fetch/https://scontent.cdninstagram.com/vp/be2c65e9fb414dd04d484bb8d7f50665/5CB5AFBE/t51.2885-15/sh0.08/e35/s640x640/41518336_1880030458786298_577146229815363603_n.jpg%3F_nc_ht=scontent.cdninstagram.com
You just need to replace the question mark with %3F.
Thanks,
Aditi0 -
Ahhh - wonderful, thank you Aditi :)
0 -
Hi Aditi
It has been a while since I asked the above question, with the solution being to escape the '?' in the URL. However, I've come across an issue with Facebook, where that solution DID work, and now no longer works, for some reason.
Consider this image:
https://scontent.xx.fbcdn.net/v/t1.0-9/60872991_1030436307152580_5052963078816137216_n.jpg?_nc_cat=107&_nc_oc=AQmYyHbgrah97a7nVTqTkqdNoO5dduqybe5o2KY-gjX2-FiryEgERedsZ14E5-luajlcsEOaqvA0MOi7chF6Bvx0&_nc_ht=scontent.xx&oh=8eea986f2c59184269b5d24294d8c918&oe=5D93A8B1
The above link will work fine. If I swap out the '?' for '%3F' and fetch the image with the Cloudinary <cloudname> URL it no longer works:https://res.cloudinary.com/<cloudname>/image/fetch/https://scontent.xx.fbcdn.net/v/t1.0-9/60872991_1030436307152580_5052963078816137216_n.jpg%3F_nc_cat=107&_nc_oc=AQmYyHbgrah97a7nVTqTkqdNoO5dduqybe5o2KY-gjX2-FiryEgERedsZ14E5-luajlcsEOaqvA0MOi7chF6Bvx0&_nc_ht=scontent.xx&oh=8eea986f2c59184269b5d24294d8c918&oe=5D93A8B1
Is this something on the Facebook side do you think (as it was working fine previously) - or am I missing something?0 -
Hi David,
The example you provided appears to work correctly via my own account: https://res.cloudinary.com/stephencloudinary/image/fetch/https://scontent.xx.fbcdn.net/v/t1.0-9/60872991_1030436307152580_5052963078816137216_n.jpg%3F_nc_cat=107&_nc_oc=AQmYyHbgrah97a7nVTqTkqdNoO5dduqybe5o2KY-gjX2-FiryEgERedsZ14E5-luajlcsEOaqvA0MOi7chF6Bvx0&_nc_ht=scontent.xx&oh=8eea986f2c59184269b5d24294d8c918&oe=5D93A8B1
There could be some account-specific configuration meaning that it works for me but not for you.
For example, there's configuration about the maximum length of filenames, which characters can be used, etc.
May I ask you to please open a support request with the exact URL you're trying including your account name so we can investigate further?
You may also see a reason for the failure in the x-cld-error header of the HTTP response
Thanks,
Stephen0 -
Hi Stephen
Thanks for the response. I've taken a look at the x-cld-error message, and it say that the public_id is too long... the URL goes over 256 characters.
I'm a little confused why it did work previously though, and now it doesn't, and why yours works on the same URL, if this is the 256 character limit has been exceeded.
I've logged a support request, as you suggested, as I'm scratching my head a little :)
Thanks again.
David0 -
Hi David,
Thanks for the update - I'll follow up on your support ticket shortly
Regards,
Stephen0
Post is closed for comments.
Comments
6 comments