Created
May 12, 2017 12:03
-
-
Save lucianomlima/dd7baa5dd8d8d6565107903092f4d704 to your computer and use it in GitHub Desktop.
React Native upload image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function uploadImage(data, frame, options) { | |
const formData = new FormData(); // eslint-disable-line no-undef | |
/** | |
* 'foto' é o nome do campo que você vai resgatar em uploadURL | |
* data é um objeto que possui o uri da imagem | |
* options são as opções da request (headers por exemplo) | |
*/ | |
formData.append('foto', { | |
...data, | |
name: 'image.jpg', | |
type: 'image/jpg' | |
}); | |
formData.append('moldura', frame); | |
const result = await api.post(config.uploadURL, formData, options).then(parseResponse); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment