https://www.npmjs.com/package/azure-storage
基于这个项目或者其他项目,是否有人使用过JavaScript包来上传azure blob存储?
我只是在这里发帖,因为我的研究结果很少,所以我认为对缺乏来自azure的原生react支持的潜在对话可能会发现一些变通方法。
我将继续尝试列出的包,并提供结果,如果成功,所以总是感谢任何回应和方向,因为它总是非常感谢!
编辑:这看起来很有趣,尽管我还没有仔细研究过它:https://www.npmjs.com/package/azure-blob-storage
发布于 2020-03-26 00:52:02
以防有人正在努力让它与这里提出的其他解决方案一起工作。这是另一个使用rn-fetch-blob的方法。此解决方案还允许使用自定义名称保存blob,例如customBlobName
import RNFetchBlob from "rn-fetch-blob";
const sasContainerUri = "https://accountname.blob.core.windows.net";
const container = "minecontainer";
const sasToken =
"sv=2019-02-02&ss=b&srt=sco&sp=rwdlac&se=2020-05-30T22:48:22Z&st=2020-05-25T14:48:22Z&spr=https&sig=otherpartofSAStoken"; // you may need to play with other html verbs in this string e.g., `sp`, `ss` e.t.c.
const localUri = Constants.platform.ios
? file.uri.replace("file://", "/")
: file.uri;
const assetPath = `${sasContainerUri}/${container}/${customBlobName}`;
try {
await RNFetchBlob.fetch(
"PUT",
`${assetPath}?${sasToken}`,
{
"x-ms-blob-type": "BlockBlob",
"content-type": "application/octet-stream",
"x-ms-blob-content-type": file.type
},
RNFetchBlob.wrap(localUri)
);
} catch (e) {
console.log("Error at saving image into Azure Storage", e);
}发布于 2019-11-26 14:40:32
是的,我用过了。
const localUri = __IS_IOS ? file.uri.replace('file://', '') : file.uri;
const assetPath = `${_trimEnd(sasContainerUri, '/')}/${container}/${uploadPath}`;
await RNFetchBlob.fetch('PUT', `${assetPath}?${sasToken}`, {
'x-ms-blob-type': 'BlockBlob',
'content-type': 'application/octet-stream',
'x-ms-blob-content-type': file.type,
}, RNFetchBlob.wrap(localUri));
return assetPath发布于 2020-02-10 12:38:34
npm install react-native-azure-blob-storage --savehttps://github.com/PosSoolutions/react-native-azure-blob-storage
https://stackoverflow.com/questions/55812140
复制相似问题