Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

vtfk/azure-storage-blob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(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). Pull requests welcome!

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-storage-blob')({
  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 the 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

About

High-level API for Azure Blob Storage operations

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors