1.0.5 • Published 2 years ago

@haddad_zineddine/azure-blob-storage v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Azure Blob Storage

Description

Azure Blob Storage is a package for node js.

Before Installation

  1. Create a Storage account and resource
  2. In the Azure Portal, go to Dashboard > Storage > your-storage-account.
  3. Note down the "AccountName", "AccountKey" obtained at Access keys.

Installation

  1. Install the package using NPM:
$ npm i -S @haddad_zineddine/azure-blob-storage
  1. Create or update your existing .env file with the following content:
AZURE_STORAGE_ACCOUNT_NAME=
AZURE_STORAGE_ACCOUNT_KEY=
AZURE_STORAGE_CONTAINER_NAME=
  1. IMPORTANT: Make sure to add your .env file to your .gitignore! The .env file MUST NOT be versionned on Git.

  2. Make sure to include the following call to your main file:

if (process.env.NODE_ENV !== 'production') require('dotenv').config();

This line must be added before any other imports!

  1. Set up the AzureStorage with the following configuration:
const azureStorage = AzureStorage.asyncSetUp({
    accountName:  process.env.AZURE_STORAGE_ACCOUNT_NAME
    accountKey: process.env.AZURE_STORAGE_ACCOUNT_KEY
    containerName: process.env.AZURE_STORAGE_CONTAINER_NAME
});
  1. Upload File to Azure Blob Storage:
const fileUrl : string = await azureStorage.uploadFile(file: UploadedFileMetadata);
  1. Delete File from Azure Blob Storage by it's blob name:
await azureStorage.deleteFile(blobName: String);

Stay in touch

License

MIT license.

1.0.2

2 years ago

1.0.1

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago