@vtfk/azure-storage-blob

1.0.3 • Public • Published

(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

See examples/example.js

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

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @vtfk/azure-storage-blob

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

6.67 kB

Total Files

4

Last publish

Collaborators

  • robinelli
  • karl-einarb
  • maccyber
  • zrrrzzt
  • sherex
  • matsand
  • runely
  • jorgtho