Created
October 18, 2017 14:23
-
-
Save stolinski/65079a9ca56a905c6540a9db173e3f8f to your computer and use it in GitHub Desktop.
Client side Image Upload To Cloudinary React Dropzone
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
// get's called from react dropzone when file is dropped | |
onImageDrop = (files) => { | |
this.handleImageUpload(files[0]); | |
} | |
async handleImageUpload(file) { | |
const data = new FormData(); | |
data.append('file', file); | |
data.append('upload_preset', CLOUDINARY_UPLOAD_PRESET); | |
const upload = await fetch(CLOUDINARY_UPLOAD_URL, { | |
method: 'POST', | |
body: data, | |
}); | |
const image = await upload.json(); | |
// then do something with image | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, how can i use this code to work with multiupload? (im trying with "react-dropzone")