The jpeg image downloaded from iPhone to S3 is not readable. But working on photoshop

I am trying to upload a jpeg image from an iOS device to S3 using the assigned URL. That's what I'm doing:

const file = {
  uri: imageURL,
  type: 'image/jpeg'
};

const formData = new FormData();
formData.append('photo', file);
formData.append('Content-Type', 'image/jpeg');

const response = await axios({
  method: 'PUT',
  headers: {
    'Content-Type': 'multipart/form-data'
  },
  url: s3PreSignedURL,
  data: formData
});

(The app is in native language responsive mode, and I use a reaction camera to take a picture.)

The problem is that the image is loading. When I download it and try to look at my mac, it says The file could not be opened. But if I open it in Photoshop, it will work. Any idea what is going on?

Here you can find a sample image: https://s3-ap-southeast-1.amazonaws.com/eyesnapdev/scans/1509856619481-71809992-b818-4637-93f1-9a75b6588c2c.jpg

+4
2

, formData , :

const file = {
  uri: imageURL,
  type: 'image/jpeg'
};

const formData = new FormData();
formData.append('photo', file);
formData.append('Content-Type', 'image/jpeg');

const response = await axios({
  method: 'PUT',
  headers: {
    'Content-Type': 'multipart/form-data'
  },
  url: s3PreSignedURL,
  data: formData // not **file**
});
+1

: ( s3 jpg , ):

--K_B9dYtGXt4.LjeMIncq0ajcL6vDRYqD1hRiwoIOJzPKYTVi8jTYT_f07RZw37Om1NJwGi content-disposition: form-data; name="photo" content-type: image/jpeg

s3 upload , .

, React, , . , :

fetch(s3PreSignedURL,{
    method:"PUT",
    headers: {
      'Content-Type': 'image/jpg'
    },
    body:{uri:imageURL}
});

axios:

axios({
  method: 'PUT',
  headers: {
    'Content-Type': 'image/jpg'
  },
  url: s3PreSignedURL,
  body:{uri:imageURL} 
});
+1

Source: https://habr.com/ru/post/1688746/


All Articles