0.2.0 • Published 6 years ago

multer-azure-storage v0.2.0

Weekly downloads
783
License
MIT
Repository
github
Last release
6 years ago

Multer Azure Storage

Multer Azure Storage provides a Storage for multer allowing for saving data to Blob Storage.

Installation

npm install multer-azure-storage

or

yarn add multer-azure-storage

Usage

Basic usage example:

var multer = require('multer')
var MulterAzureStorage = require('multer-azure-storage')
var upload = multer({
  storage: new MulterAzureStorage({
    azureStorageConnectionString: 'DefaultEndpointsProtocol=https;AccountName=mystorageaccount;AccountKey=mykey;EndpointSuffix=core.windows.net',
    containerName: 'photos',
    containerSecurity: 'blob'
  })
})

Then use upload as described in multer documentation

File information

Each file added using Multer Azure Storage contains the following information:

KeyDescriptionNote
fieldnameField name specified in the formadded by multer
originalnameName of the file on the user's computeradded by multer
encodingEncoding type of the fileadded by multer
mimetypeMime type of the fileadded by multer
blobName of created blob
containerName of container in which blob was created
blobTypeType of blobBlockBlob - From the result of call to azure's getBlobProperties() of blobService
sizeSize of the blobFrom the result of call to azure's getBlobProperties() of blobService
etagEtagFrom the result of call to azure's getBlobProperties() of blobService
metadataBlob's metadataFrom the result of call to azure's getBlobProperties() of blobService
urlUrl to access the blob

Options

To setup the connection to Azure Storage either the connection string (azureStorageConnectionString) is required or the combination of storage account (azureStorageAccount) and access key (azureStorageAccessKey)

Using Azure storage connection string

Parameter NameTypeSample Value
azureStorageConnectionStringstring'DefaultEndpointsProtocol=https;AccountName=mystorageaccount;AccountKey=mykey;EndpointSuffix=core.windows.net'
containerNamestring'photos'
containerSecuritystring (optional)'blob' or 'container', defaults to blob
fileNamefunction (optional)function that receives a file reference and allows customization of the file name

Using Azure storage account name and access key

Parameter NameTypeSample Value
azureStorageAccessKeystring'dcs@3asd@...' - Access Key related to your storage account
azureStorageAccountstring'mystorageaccount'
containerNamestring'photos'
containerSecuritystring (optional)'blob' or 'container', defaults to blob
fileNamefunction (optional)function that receives a file reference and allows customization of the file name

For more information about the meaning of individual parameters please check Azure documentation on node.js integration.

Tests

Not implemented yet

License

MIT