Skip to content

Instantly share code, notes, and snippets.

@hannigand
Last active January 12, 2018 10:58
Show Gist options
  • Save hannigand/cb82e960f5b96fe5858a12efba10986d to your computer and use it in GitHub Desktop.
Save hannigand/cb82e960f5b96fe5858a12efba10986d to your computer and use it in GitHub Desktop.
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