How to use the azure-storage.Constants function in azure-storage

To help you get started, we’ve selected a few azure-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ItalyPaleAle / SMCloudStore / packages / azure-storage / src / AzureStorageProvider.ts View on Github external
return new Promise((resolve, reject) => {
                // The following properties/methods aren't defined in the typings file
                const blobTypeConstants = (Azure.Constants.BlobConstants as any).ListBlobTypes
                const listBlobType = (type == 'prefix') ? blobTypeConstants.Directory : blobTypeConstants.Blob

                const clientAny = this._client as any
                clientAny._listBlobsOrDircotriesSegmentedWithPrefix(container, prefix || null, continuationToken, listBlobType, {delimiter: '/'}, (err, response) => {
                    if (err) {
                        return reject(err)
                    }

                    // Iterate through the list of items and add objects to the result list
                    for (const i in response.entries) {
                        if (response.entries.hasOwnProperty(i)) {
                            const e = response.entries[i]

                            // Is this a prefix (folder) or object? If etag is present, it's an object
                            if (e.etag) {
                                const res = {
github compulim / azure-storage-fs / test / parseSASToken.js View on Github external
'use strict';

const assert                                = require('assert');
const qs                                    = require('qs');
const { AccountSasConstants }               = require('azure-storage').Constants;

const parseSASToken = require('../lib/util/parseSASToken');

const { Permissions, Protocols, Resources }                = AccountSasConstants;
const { parsePermissions, parseResources, parseProtocols } = parseSASToken;

describe('Parse SAS token', () => {
  context('parse protocols', () => {
    it('should parse "https" as HTTPSONLY', () => {
      assert.equal(parseProtocols('https'), Protocols.HTTPSONLY);
    });

    it('should parse "http" as HTTPSORHTTP', () => {
      assert.equal(parseProtocols('http'), Protocols.HTTPSORHTTP);
    });
github scality / Arsenal / lib / storage / data / external / AzureClient.js View on Github external
const url = require('url');

const azure = require('azure-storage');
const errors = require('../../../errors');
const azureMpuUtils = require('../../../s3middleware/azureHelpers/mpuUtils');
const { validateAndFilterMpuParts } =
    require('../../../s3middleware/processMpuParts');

const { createLogger, logHelper, translateAzureMetaHeaders } =
    require('./utils');

const constants = require('../../../constants');
const packageVersion = require('../../../../package.json').version;

azure.Constants.USER_AGENT_PRODUCT_NAME = constants.productName;
azure.Constants.USER_AGENT_PRODUCT_VERSION = packageVersion;

class AzureClient {
    constructor(config) {
        this._azureStorageEndpoint = config.azureStorageEndpoint;
        this._azureStorageCredentials = config.azureStorageCredentials;
        this._azureContainerName = config.azureContainerName;
        this._client = azure.createBlobService(
            this._azureStorageCredentials.storageAccountName,
            this._azureStorageCredentials.storageAccessKey,
            this._azureStorageEndpoint);
        this._dataStoreName = config.dataStoreName;
        this._bucketMatch = config.bucketMatch;
        if (config.proxy && config.proxy.url) {
            const parsedUrl = url.parse(config.proxy.url);
            if (!parsedUrl.port) {
                parsedUrl.port = 80;
github scality / Arsenal / lib / storage / data / external / AzureClient.js View on Github external
const url = require('url');

const azure = require('azure-storage');
const errors = require('../../../errors');
const azureMpuUtils = require('../../../s3middleware/azureHelpers/mpuUtils');
const { validateAndFilterMpuParts } =
    require('../../../s3middleware/processMpuParts');

const { createLogger, logHelper, translateAzureMetaHeaders } =
    require('./utils');

const constants = require('../../../constants');
const packageVersion = require('../../../../package.json').version;

azure.Constants.USER_AGENT_PRODUCT_NAME = constants.productName;
azure.Constants.USER_AGENT_PRODUCT_VERSION = packageVersion;

class AzureClient {
    constructor(config) {
        this._azureStorageEndpoint = config.azureStorageEndpoint;
        this._azureStorageCredentials = config.azureStorageCredentials;
        this._azureContainerName = config.azureContainerName;
        this._client = azure.createBlobService(
            this._azureStorageCredentials.storageAccountName,
            this._azureStorageCredentials.storageAccessKey,
            this._azureStorageEndpoint);
        this._dataStoreName = config.dataStoreName;
        this._bucketMatch = config.bucketMatch;
        if (config.proxy && config.proxy.url) {
            const parsedUrl = url.parse(config.proxy.url);
            if (!parsedUrl.port) {
github compulim / azure-storage-fs / lib / util / parseSASToken.js View on Github external
'use strict';

const qs                                    = require('qs');
const { AccountSasConstants }               = require('azure-storage').Constants;
const { Permissions, Protocols, Resources } = AccountSasConstants;

function parseSASToken(sasToken) {
  sasToken = qs.parse((sasToken || '').replace(/^\?/, ''));

  return {
    AccessPolicy: {
      Expiry          : sasToken.se && new Date(sasToken.se),
      IPAddressOrRange: sasToken.sip,
      Permissions     : parsePermissions(sasToken.sp),
      Protocols       : parseProtocols(sasToken.spr),
      ResourceTypes   : parseResources(sasToken.sr),
      Start           : sasToken.st && new Date(sasToken.st)
    }
  };
}