0

I'm using React Native and I need to send an image in base64 format using a POST method of binary type.

const session = await Auth.currentSession();

    const config = {
      headers: {
        "Content-Type": "image/jpeg",
        "x-amz-acl": "public-read",
        Authorization: session.getIdToken().getJwtToken(),
      },
    };

    const API = `event/${eventData.id}/photos`;

    const HOST = "https://host.com/";
    const url = `${HOST}/${API}`;

    const result = await axios.post(url, photo.uri, config);

    console.log("Result: ", result);

But I'm running into this error: [AxiosError: Request failed with status code 400]

My postman:

Authorization Headers

I'm trying to get the right response data from AWS S3.

Jamiu S.
  • 5,257
  • 5
  • 12
  • 34
Neta
  • 1
  • Take a look at this:https://stackoverflow.com/questions/49803215/read-blob-file-in-base64-and-upload-on-the-server. – user18309290 Nov 03 '22 at 15:46
  • You can simply use https://github.com/react-native-image-picker/react-native-image-picker . It generate base64 image data for you to upload – Fiston Emmanuel Nov 03 '22 at 23:48

0 Answers0