-1

I'm trying to upload an image on Google cloud console with javascript, but it's not working at all.

I have tried with the multiple post URL's https://storage.googleapis.com/upload/storage/v1/b/${bucketName}/o/ https://storage.googleapis.com/upload/storage/v1/b/${bucketName}/o?uploadType=media&name=${filename}

but none of them works, it always says 404 not found.

I want to upload the image on google cloud console with help of Javascript or jQuery

1
  • I was trying to post the base64 of the image you can see in the attachment, data is showing in the Network Payload, but its not uploading to the server. giving me an error. Commented Jan 11, 2023 at 8:46

1 Answer 1

0

A POST to the second URL pattern you listed, https://storage.googleapis.com/upload/storage/v1/b/BUCKET_NAME/o?uploadType=media&name=OBJECT_NAME, is correct.

There are several alternatives you could try, for example a PUT to the pattern https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME.

Getting a 404 is unexpected and somewhat hard to diagnose without the exact URL. The most obvious cause would be that a bucket of that name doesn't exist. Check for typos? The second most likely reason is that you are accidentally doing a PUT or a GET instead of a POST.

Try making the same call with cURL, wget, or similar to see if you can reproduce the issue with another tool.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.