2.0.3 • Published 2 years ago

react-native-azure-blob-storage v2.0.3

Weekly downloads
34
License
MIT
Repository
github
Last release
2 years ago

react-native-azure-blob-storage

Getting started

$ npm install react-native-azure-blob-storage --save

Mostly automatic installation

$ react-native link react-native-azure-blob-storage

Usage

import React, { Component } from 'react';
import { Button, StyleSheet, ScrollView, View, Image, TouchableOpacity, Platform } from 'react-native';
import { EAzureBlobStorageFile } from 'react-native-azure-blob-storage';
import CameraRoll from "@react-native-community/cameraroll";

 class App extends Component {
  state = {
    photos: []
  }
  async componentDidMount() {
    EAzureBlobStorageFile.configure(
      "Account Name", //Account Name
      "Account Key", //Account Key
      "images", //Container Name
       false //SAS Token 
    );
  }
  _handleButtonPress = () => {
    CameraRoll.getPhotos({
      first: 20,
      assetType: 'Photos',
    })
      .then(r => {
        this.setState({ photos: r.edges });
      })
      .catch((err) => {
        console.log("Errror", err)
      });
  };
  render() {
    return (
      <View>
        <Button title="Load Images" onPress={this._handleButtonPress} />
        <ScrollView>
          {this.state.photos.map((p, i) => {
            return (
              <TouchableOpacity
                onPress={ () => {
                   EAzureBlobStorageFile.uploadFile({
                              "filePath":Platform.OS === 'android'?filePath:'file://' + filePath,
                              "contentType":"audio/wav",
                              "fileName":"test.wav"
                            }).then((name) => {  
                              console.log('File Name  ' + name);  
                            }).catch((error) => {  
                                console.log('Error' + error); 
                            }); 
                }}
              >
                <Image
                  key={i}
                  style={{
                    width: 300,
                    height: 100,
                  }}
                  source={{ uri: p.node.image.uri }}
                />
              </TouchableOpacity>
            );
          })}
        </ScrollView>
      </View>
    );
  }
}

Example

Ios requires a relative path Android Will work with either 
EAzureBlobStorageImage.uploadFile('/Route To Image.PNG'')
1.3.4

2 years ago

1.2.4

2 years ago

2.0.3

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.3

3 years ago

1.2.1

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago