Skip to content

Latest commit

 

History

History
76 lines (60 loc) · 1.63 KB

README.md

File metadata and controls

76 lines (60 loc) · 1.63 KB

react-native-azure-blob-storage-manager

This package help you to upload file and assests from react native project to your azure blob storage service

Install

Step 1

npm i react-native-azure-blob-storage-manager --save

Step 2 Dependencies

npm install --save react-native-background-upload

iOS

cd ios
pod install

Manual Installation

please follow each dependensy document :

Usage

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);

  }