Socket
Socket
Sign inDemoInstall

azure-storage-as-promised

Package Overview
Dependencies
64
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    azure-storage-as-promised

Wrapper on top of azure-storage with promises.


Version published
Maintainers
1
Install size
8.94 MB
Created

Readme

Source

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'.

Keywords

FAQs

Last updated on 14 Sep 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc