首页 > 解决方案 > React-Native blob 不存在

问题描述

我需要向 AWS S3 发送一个 blob。

我正在使用 react-native-fetch-blob 并尝试使用以下内容来获得一个想法:但我总是得到错误 build does not exist on type

https://github.com/wkh237/rn-firebase-storage-upload-sample/blob/master/index.common.js

import RNFetchBlob from 'react-native-fetch-blob';
const Blob = RNFetchBlob.polyfill.Blob;
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest;
window.Blob = Blob;

Blob
.build(rnfbURI, { type : 'image/png;'})
.then((blob) => {
  // upload image using Firebase SDK
  firebase.storage()
    .ref('images')
    .child(fileName)
    .put(blob, { contentType : 'image/jpg' })
    .then((snapshot) => {
      console.log('Uploaded', snapshot.totalBytes, 'bytes.');
      console.log(snapshot.metadata);
      var url = snapshot.metadata.downloadURLs[0];
      console.log('File available at', url);
    }).catch(function(error) {
      console.error('Upload failed:', error);
    })
  }

标签: react-native

解决方案


推荐阅读