This package help you to upload file and assests from react native project to your azure blob storage service
npm i react-native-azure-blob-storage-manager --save
npm install --save react-native-background-upload
cd ios
pod install
please follow each dependensy document :
Import library
import { azureblobfetch, initAzureBlob } from 'react-native-azure-blob-storage-manager/azurblobstorage'
import Upload from 'react-native-background-upload'
init azure blob storage setting
constructor(props) {
super(props);
initAzureBlob(
{
storageKey: `${YOUR_BLOB_STORAGE_SECRET_KEY}`,
account: `${YOUR_ACCOUNT_NAME}`,
version: '2018-03-28'
})
....
}
upload file from cameraroll :
uploadAzure = async (assest) => {
const res = await azureblobfetch({
assest: assest,
container: "images" //your countainer name,
filenameprefix: "test" //add before the autogenrated file name,
type: 'Upload'
})
Upload.addListener('progress', res.uploadId, (data) => {
console.log(`Progress: ${data.progress}% `)
})
Upload.addListener('cancelled', res.uploadId, (data) => {
console.log(`Cancelled!`)
})
Upload.addListener('completed', res.uploadId, (data) => {
// data includes responseCode: number and responseBody: Object
console.log(data)
})
console.log(res);
}