Guest User

Untitled

a guest
Oct 19th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // get's called from react dropzone when file is dropped
  2. onImageDrop = (files) => {
  3. this.handleImageUpload(files[0]);
  4. }
  5.  
  6. async handleImageUpload(file) {
  7. const data = new FormData();
  8. data.append('file', file);
  9. data.append('upload_preset', CLOUDINARY_UPLOAD_PRESET);
  10. const upload = await fetch(CLOUDINARY_UPLOAD_URL, {
  11. method: 'POST',
  12. body: data,
  13. });
  14. const image = await upload.json();
  15. // then do something with image
  16. }
Add Comment
Please, Sign In to add comment