Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vtfk/azure-storage-blob
High-level API for Azure Blob Storage operations
https://github.com/vtfk/azure-storage-blob
azure blob functions nodejs storage
Last synced: about 1 month ago
JSON representation
High-level API for Azure Blob Storage operations
- Host: GitHub
- URL: https://github.com/vtfk/azure-storage-blob
- Owner: vtfk
- License: mit
- Created: 2019-03-28T21:30:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T03:21:47.000Z (8 months ago)
- Last Synced: 2024-05-28T14:58:44.197Z (7 months ago)
- Topics: azure, blob, functions, nodejs, storage
- Language: JavaScript
- Homepage:
- Size: 44.9 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# (WIP) azure-blob-storage
High-level API for Azure Blob Storage operations.
Uses the [@azure/storage-blob](https://www.npmjs.com/package/@azure/storage-blob) SDK
# Install
```bash
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`
```js
const storage = require('@vtfk/azure-storage-blob')({
connectionString: ''
/* optional timeout in ms
timeout: 30 * 1000
*/
})
```## Container operations
### List containers in storage account
```js
const { containerItems } = await storage.list()
```### Create a container
```js
await storage.create('containername')
```### Remove a container
```js
await storage.remove('containername')
```## Blob operations
First, connect to the desired container
```js
const container = storage.container('containername')
```### List blobs in container
```js
const { segment: { blobItems } } = await container.list()
```### Write text to blob
```js
await container.writeText('test.json', JSON.stringify({ text: 'One thought fills immensity.' }))
```### Read blob
```js
const content = await container.read('test.json')
```### Remove blob
```js
await container.remove('test.json')
```# Examples
See [examples/example.js](examples/example.js)
To run `example.js` create file `.env` in project root with following content
```
BLOB_SERVICE_SAS_URL=
```And run `npm run example`
# License
[MIT](LICENSE)