Q:

upload a file from react native expo to s3

// Example with Expo / axios / buffer
import { Buffer } from 'buffer' // import buffer

const { base64 } = await Expo.ImagePicker.launchImageLibraryAsync({
 base64: true
})

const url = await api.getUploadUrlFromS3() // from your own back-end server
const result = await api.uploadAsync(url, new Buffer(base64, 'base64')) // upload it

console.log(result) // DONE!

[...]
// api.js
function upload(url, image) {
 return axios.put(url, image, {
    headers: { 'Content-Type': 'image/png' } // add Content-Type on header
  })
}
0

New to Communities?

Join the community