Answers for "upload a file from react native expo to s3"

0

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
  })
}
Posted by: Guest on July-31-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language