AWS S3 update image using pre-signed URL (Axios-PUT Request)

  amazon-s3, axios, javascript, jpeg

I’m trying to update a local JPG image file into an S3 bucket using the REST PUT request and Axios.

I managed to send the PUT request and to get a positive answer from AWS S3 Service but what it’s been upload is not a JPG file but a JSON file.

This is the code that I’m using:

    //Create the FormData
    var data = new FormData();
    data.append('file', fs.createReadStream(image_path));

   //Send the file to File-system
   console.log("Sending file to S3...");
   const axiosResponse = await axios.put(image_signed_url, {
       data: data,
       headers: { 'Content-Type': 'multipart/form-data' }
     }).catch(function(error) {
      return null;

I have already try to change the headers to {'Content-Type': 'application/octet-stream' } but I obtained the same result.

Source: Ask Javascript Questions