Last active
January 12, 2018 10:58
-
-
Save hannigand/cb82e960f5b96fe5858a12efba10986d to your computer and use it in GitHub Desktop.
This file contains 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
const uploadFile = (file, callback) => { | |
const date = Date.now(); | |
const signature = `timestamp=${date}`; | |
RNFetchBlob.fetch( | |
'POST', | |
'https://api.cloudinary.com/v1_1/BUCKET_NAME/video/upload', | |
{ | |
'Content-Type': 'multipart/form-data' | |
}, | |
[ | |
{ | |
name: 'file', | |
filename: 'vid.mov', | |
data: RNFetchBlob.wrap(file) | |
}, | |
{ | |
name: 'api_key', | |
data: '' | |
}, | |
{ | |
name: 'timestamp', | |
data: date | |
}, | |
{ | |
name: 'signature', | |
data: sha1(`${signature}{ANOTHER_VALUE__NEED_TO_READ_DOCS) | |
} | |
] | |
) | |
.then(res => { | |
const data = JSON.parse(res.data); | |
const videoUrl = data.url; | |
callback(videoUrl); | |
}) | |
.catch(err => { | |
console.log(err); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment