This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

azure-storage-as-promised
TypeScript icon, indicating that this package has built-in type declarations

0.9.0 • Public • Published

A promise wrapper for Azure Storage. Github repo

You can read about Azure Storage.

Includes

  • Files
  • Blobs
  • Queues

Opinions

If the outermost storage inside the resource, such as a share or container, doesn't exist, it is created as part of the request.

Notes

For Blob storage, the base directory is known as an empty string.

Prerequisites

  • Azure subscription
  • Azure Storage resource and its connection string, found on the Keys page of the resource in the Azure portal.

Dependencies

Install via NPM

npm install azure-storage-as-promised

Usage in tests

The tests include usage of objects.

Usage with Blob in Javascript

This method signature changed in V 0.9.0.

require('dotenv').config();
const BlobStorage = require("azure-storage-as-promised").Blob;
const myblob = new BlobStorage(process.env.AZURESTORAGECONNECTIONSTRING);

const container="function-blob-upload";
const directory=""; // root dir is empty string
const blob="short.txt";

const finalBlob = directory + '/' + blob;

myblob.getBlobProperties(container, blob).then(results=>{
    console.log(JSON.stringify(results));
}).catch(err=>{
    console.log(err);
})

Usage with File in typescript

// import classes in package
import { File } from 'azure-storage-as-promised';

// set connection string
const fileAzure = new File(process.env.AZURESTORAGECONNECTIONSTRING);

// create directory which creates share
const directoryResult = await fileAzure.createDirectory(share, directory, undefined);

// check that share does exist
const shareResult:any = await fileAzure.doesShareExist(share);

// check that directory does exist
const doesDirectoryExist = await fileAzure.doesDirectoryExist(share, directory);

// add file
const fileResult:any = await fileAzure.addFile(share, directory, fileName, fileFullPath, optionalContentSettings, optionalMetadata);

// get file properties
const fileProperties:any = await fileAzure.getFileProperties(share, directory, fileName);

// get file download
const url:any = await fileAzure.getFileUrl(share, directory, fileName);

// get base directories, empty string is base directory
const directoriesAndFiles:any = await fileAzure.getDirectoriesAndFiles(share, "");

// get subdir files
const subDirectoriesAndFiles:any = await fileAzure.getDirectoriesAndFiles(share, directoriesAndFiles.directories[0].name);

// delete directory and all files within
const deleteDirectoryResults:any = await fileAzure.deleteDirectory(share, directoriesAndFiles.directories[0].name);

// check that directory doesn't exist
const doesDirectoryExist2:any = await fileAzure.doesDirectoryExist(share, directory);

// delete Share
const deleteShareResult:any = await fileAzure.deleteShare(share);

Run tests

npm run test

Change log

  • Version 0.9.0

    Blob.getBlobProperties has new signature - directory is now a part of blob. For example, if directory is 'abc' and blob name is 'xyz', these are passing in as the blob variable, 'xyz/abc'.

Package Sidebar

Install

npm i azure-storage-as-promised

Weekly Downloads

7

Version

0.9.0

License

Apache-2.0

Unpacked Size

57.7 kB

Total Files

22

Last publish

Collaborators

  • diberry