@vtfk/azure-storage-blob
v1.0.3
Published
High-level API for Azure Blob Storage operations
Downloads
4
Readme
(WIP) azure-blob-storage
High-level API for Azure Blob Storage operations.
Uses the @azure/storage-blob SDK
Install
npm i --save @vtfk/azure-storage-blob
API
Connection
Currently it only supports Shared Access Signature (SAS)
Go to https://portal.azure.com
Storage accounts -> Your Storage account -> Shared access signature
Generate a SAS with desired start
and end
time.
Copy and use Blob service SAS URL
as connectionString
const storage = require('@vtfk/azure-blob-storage')({
connectionString: '<BLOB_SERVICE_SAS_URL>'
/* optional timeout in ms
timeout: 30 * 1000
*/
})
Container operations
List containers in storage account
const { containerItems } = await storage.list()
Create a container
await storage.create('containername')
Remove a container
await storage.remove('containername')
Blob operations
First, connect to a desired container
const container = storage.container('containername')
List blobs in container
const { segment: { blobItems } } = await container.list()
Write text to blob
await container.writeText('test.json', JSON.stringify({ text: 'One thought fills immensity.' }))
Read blob
const content = await container.read('test.json')
Remove blob
await container.remove('test.json')
Examples
To run example.js
create file .env
in project root with following content
BLOB_SERVICE_SAS_URL=<BLOB_SERVICE_SAS_URL>
And run npm run example