Fetch image not working with some images on firebase
I'm trying to fetch images from a firebase storage. Some images are fetched successfully such as:
https://res.cloudinary.com/sangsoft/image/fetch/https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fsangcafe-prod.appspot.com%2Fo%2Fimages%252F1622451516497-user_KxcMIYfTk2aZKF2ah66Xl2aVZga2%252Frestaurant%252F1622451516378-7493E206-885D-4191-98B0-AC23FDF54C79.jpeg%3Falt%3Dmedia%26token%3D4ce2b780-3188-49b1-9c04-94bd42f2b9a4
Original image url: https://firebasestorage.googleapis.com/v0/b/sangcafe-prod.appspot.com/o/images%2F1622451516497-user_KxcMIYfTk2aZKF2ah66Xl2aVZga2%2Frestaurant%2F1622451516378-7493E206-885D-4191-98B0-AC23FDF54C79.jpeg?alt=media&token=4ce2b780-3188-49b1-9c04-94bd42f2b9a4
But some images returns an error code 400:
https://res.cloudinary.com/sangsoft/image/fetch/https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fsangcafe-prod.appspot.com%2Fo%2Fimages%252F1627392823571-user_kH4FgxBhV9TfB96iy7UFt0Y9Zsw2%252Frestaurant%252F1627392823527-226114931_515751749757548_6118847938422666772_n.jpg%3F%253Falt%3Dmedia%26token%3Dab2458f7-341e-40a1-bacc-b0d71eca5051%26alt%3Dmedia
Original image url: https://firebasestorage.googleapis.com/v0/b/sangcafe-prod.appspot.com/o/images%2F1611905250954-user_N1lqLeUI0dcIs3v0ddCTKqrSaaD3%2Frestaurant%2F1611905250946-143488827_713098432735513_5002017796728151475_n.jpg?%3Falt=media&token=9d1d632b-de47-48de-aae0-d8752100d872&alt=media
1
-
If you look at the x-cld-error response header, it mentions that the public id is too long. I would recommend using auto-upload instead to shorten the URL. https://cloudinary.com/documentation/fetch_remote_images#auto_upload_remote_files
1 -
I have mapped a subfolder for auto-uploading according to the documentation:
firebase -> https://firebasestorage.googleapis.com/v0/b/sangcafe-prod.appspot.com/o/
But when I try to access these urls it always returns "public ID is invalid"
Original image url: https://firebasestorage.googleapis.com/v0/b/sangcafe-prod.appspot.com/o/images%2F1611905250954-user_N1lqLeUI0dcIs3v0ddCTKqrSaaD3%2Frestaurant%2F1611905250946-143488827_713098432735513_5002017796728151475_n.jpg?%3Falt=media&token=9d1d632b-de47-48de-aae0-d8752100d872&alt=media
Without URI encoding:
https://res.cloudinary.com/sangsoft/image/upload/firebase/images%2F1611905250954-user_N1lqLeUI0dcIs3v0ddCTKqrSaaD3%2Frestaurant%2F1611905250946-143488827_713098432735513_5002017796728151475_n.jpg?%3Falt=media&token=9d1d632b-de47-48de-aae0-d8752100d872&alt=mediaWith URI encoding:
https://res.cloudinary.com/sangsoft/image/upload/firebase/images%252F1611905250954-user_N1lqLeUI0dcIs3v0ddCTKqrSaaD3%252Frestaurant%252F1611905250946-143488827_713098432735513_5002017796728151475_n.jpg%3F%253Falt%3Dmedia%26token%3D9d1d632b-de47-48de-aae0-d8752100d872%26alt%3Dmedia1 -
Hi Trung,
A URL with special characters should be double-escaped, like this:0
Post is closed for comments.
Comments
3 comments