Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. // img
  2. // {
  3. // uri: '"assets-library://asset/asset.JPG?id=SOME_ID&ext=JPG"',
  4. // md5: "some md5"
  5. // }
  6.  
  7. // copy into cache dir first
  8. const path = FileSystem.cacheDirectory + img.md5
  9. await FileSystem.copyAsync({
  10. from: img.uri,
  11. to: path
  12. })
  13.  
  14. // read that and do upload
  15. const file = await FileSystem.readAsStringAsync(path, {
  16. encoding: FileSystem.EncodingTypes.Base64
  17. })
  18.  
  19. const payload = {
  20. title: 'some awesome photo',
  21. image: file
  22. }
  23.  
  24. fetch('somewhere', {
  25. method: 'POST',
  26. body: JSON.stringify(payload)
  27. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement