-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

MrUpsidown
  • 21,592
  • 15
  • 77
  • 131
Parker S
  • 11
  • 2
  • 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. – Parker S Jan 11 '23 at 08:46

1 Answers1

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.

Brandon Yarbrough
  • 37,021
  • 23
  • 116
  • 145