D
D
Destell2019-07-24 17:24:45
JavaScript
Destell, 2019-07-24 17:24:45

What is the correct way to upload a file via axios to s3?

What is - a request with the id of the picture goes to the backend, the name for the picture and a link for put are received in response.
What is missing is an understanding of why exactly it does not work.
I use the method to send

function upload(url, image) {
  const formData = new FormData();
  formData.append("image", image);
  formData.append("Content-Type", "image/jpeg");

  return server.axios.put(url, formData, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
}

to which I pass the address and object
const image = {
          uri: file.path,
          type: "image/jpeg",
          name: newName
 };

The response is 405.
I also tried to write something like this formData.append("image", //image uri, //new image name);
What's my mistake?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2019-07-24
@inoise

Use the AWS SDK and don't chew your brain)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question