0
votes

I am trying to upload images. I have got my signedUrl to my bucket, but I can't make a proper http put request. I am using the superagent library.

const req = superagent.put(url)
  .attach(file.name, file)
  .end();

The file object is https://developer.mozilla.org/en-US/docs/Web/API/File End the url is the signedUrl from my server. Without the attachment I can upload an empty file. But with the attachment I get an http 403 error. How can I upload files with this signedUrl?

1
403 codes are when the server understands the call, but some authorization fails. How are you generating the signedURL you are passing to the request?Federico Panunzio

1 Answers

0
votes

I went through the same issue because the Content-Type header was missing from my request. Try to add it like:

const req = superagent.put(url)
  .attach(file.name, file)
  .set('Content-Type', file.type);
  .end();

Hope it helps!