Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@vtfk/azure-blob-client
Advanced tools
Readme
An convenient library for working with Azure storage blobs
npm i @vtfk/azure-blob-client
Name | Example |
---|---|
AZURE_BLOB_CONNECTIONSTRING | DefaultEndpointsProtocol=https;AccountName=[AccountName];AccountKey=[AccountKey];EndpointSuffix=core.windows.net |
AZURE_BLOB_CONTAINERNAME | Blobs |
const blobClient = require('@vtfk/azure-blob-client');
// OR just require the functions you need with destructoring
const { list, get, create, remove } = require('@vtfk/azure-blob-client');
Saves content to a given path
// Create a blob with path test.txt
await blobClient.save('test.txt', 'testdata');
await blobClient.save('test/test2.txt', 'data:plain/text;utf-8,test2');
await blobClient.save('test/folder1/test3.txt', 'data:plain/text;utf-8,test3');
We recommend using the dataUrl-format for storing data as it makes it easier to work with after it is retreived. Example: img-tags in HTML can display them as pictures and browsers can easily handle and download them.
If stored in dataUrl format the MIME type and encoding will be parsed when retreiving the data.
List one or more blobs matching the provided path
// Gets all blobs that has a path that starts with test
await blobClient.list('test');
// Gets all blobs in container
await blobClient.list('*');
// Yields
[
{
name: 'test.txt',
path: 'test.txt',
blobType: 'BlockBlob',
createdOn: 2021-12-17T13:42:43.000Z,
lastModified: 2021-12-17T13:46:18.000Z,
lastAccessedOn: undefined
},
{
name: 'test2.txt',
path: 'test/test2.txt',
blobType: 'BlockBlob',
createdOn: 2021-12-17T13:42:43.000Z,
lastModified: 2021-12-17T13:46:18.000Z,
lastAccessedOn: undefined
},
{
name: 'test3.txt',,
path: 'test/folder1/test3.txt',
blobType: 'BlockBlob',
createdOn: 2021-12-17T13:42:43.000Z,
lastModified: 2021-12-17T13:46:18.000Z,
lastAccessedOn: undefined
}
]
Get one or more blobs with its data
// Gets a blob with name/path test.txt
await blobClient.get('test.txt')
// Yields
{
name: 'test.txt',
path: 'test.txt',
extension: 'txt',
data: 'testdata'
}
// Gets a blob with name/path test.txt
await blobClient.get('test/')
// Yields
[
{
name: 'test2.txt',
path: 'test/test2.txt',
extension: 'txt',
type: 'plain/test',
encoding: 'utf-8',
data: 'data:plain/text;utf-8,test2'
},
{
name: 'test3.txt',
path: 'test/folder1/test3.txt',
extension: 'txt',
type: 'plain/test',
encoding: 'utf-8',
data: 'data:plain/text;utf-8,test3'
}
]
If you for example need get
to return base64 instead of a bufferstring, you can specify encoding in the options-parameter.
See valid encodings in NodeJs official documentation
// Gets a blob with name/path test.pdf and returns the content as a base64 string
await blobClient.get('test.pdf', { encoding: 'base64' })
// Yields
{
name: 'test.pdf',
path: 'test.pdf',
extension: 'pdf',
data: 'JVBERi0xLjQNCiX5+pr==....'
}
Removes one or more blobs patching the provided path
// Removes the blob with path test.txt
await blobClient.remove('test.txt');
// Yields
[ 'test.txt' ]
// Removes all blobs starting with test
await blobClient.remove('test');
// Yields
[ 'test/test2.txt', 'test/folder1/test3.txt' ]
Creates and returns a BlobServiceClient for working with lower-level API
// Create the client
const client = await blobClient.createBlobServiceClient();
Creates and returns a ContainerClient for working with lower-level API
// Create the client
const client = await blobClient.createContainerClient();
All functions takes in an optional options object
// Create the options object
const options = {
connectionString: 'Azure storage account connection string',
containerName: 'Azure storage account container name '
}
// Get blobs with provided options
await blobClient.get('test.txt', options);
FAQs
A client for working with Azure storage blobs
The npm package @vtfk/azure-blob-client receives a total of 1 weekly downloads. As such, @vtfk/azure-blob-client popularity was classified as not popular.
We found that @vtfk/azure-blob-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.