https://www.npmjs.com/package/azure-storage
Based on this project or potentially another, has anyone used any JavaScript package for azure blob storage uploads?
I only post here as my research has returned little results, so I though a potential conversation into the lack of react native support from azure might uncover some workarounds.
I will continue to try the listed package and provide results if successful, so as always thanks for any response and direction as it's always greatly appreciated!
Edit: This looks interesting, though I have not looked into it in great detail: https://www.npmjs.com/package/azure-blob-storage
In case someone is struggling to make it work with other solutions proposed here. Here is another one using rn-fetch-blob
. This solution also allows saving a blob with custom name e.g., 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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With