How to use the fast-azure-storage.Blob function in fast-azure-storage

To help you get started, we’ve selected a few fast-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 taskcluster / taskcluster / services / auth / src / azure.js View on Github external
// Get parameters
  let account = req.params.account;
  let container = req.params.container;
  let level = req.params.level;

  // Check that the client is authorized to access given account and container
  await req.authorize({level, account, container, levelIsReadOnly: level === 'read-only'});

  // Check that the account exists
  if (!this.azureAccounts[account]) {
    return res.reportError('ResourceNotFound',
      `Account '${level}' not found, can't delegate access.`);
  }

  // Construct client
  let blob = new azure.Blob({
    accountId: account,
    accessKey: this.azureAccounts[account],
  });

  // Create container ignore error, if it already exists
  if (level === 'read-write') {
    const key = `${account}/${container}`;
    if (!containerLastCreated[key] || new Date() - containerLastCreated[key] > 6 * 3600 * 1000) {
      try {
        await blob.createContainer(container);
      } catch (err) {
        if (err.code !== 'ContainerAlreadyExists') {
          throw err;
        }
      }
      containerLastCreated[key] = new Date();
github taskcluster / taskcluster / infrastructure / tooling / src / backup / backup.js View on Github external
const backupContainer = async ({azureCreds, s3, bucket, containerName, utils}) => {
  const stream = new zlib.createGzip();
  const container = new azure.Blob(azureCreds);

  // Versioning is enabled in the backups bucket so we just overwrite the
  // previous backup every time. The bucket is configured to delete previous
  // versions after N days, but the current version will never be deleted.
  let upload = s3.upload({
    Bucket: bucket,
    Key: `${azureCreds.accountId}/container/${containerName}`,
    Body: stream,
    StorageClass: 'STANDARD_IA',
  }).promise();

  let count = 0;
  let nextUpdateCount = 1000;
  let marker;
  do {
    let results = await container.listBlobs(containerName, {marker});
github taskcluster / taskcluster / infrastructure / tooling / src / backup / restore.js View on Github external
let restoreContainer = async ({azureCreds, s3, bucket, containerName, destContainerName, versionId, utils}) => {
  let blobsvc = new azure.Blob(azureCreds);

  try {
    await blobsvc.createContainer(destContainerName);
  } catch (err) {
    if (err.code !== 'ContainerAlreadyExists') {
      throw err;
    }
    throw new Error(`Refusing to overwrite container ${destContainerName} as it already exists!`);
  }

  try {
    await s3.headObject({
      Bucket: bucket,
      Key: `${azureCreds.accountId}/container/${containerName}`,
      VersionId: versionId,
    }).promise();
github taskcluster / taskcluster / services / auth / src / azure.js View on Github external
}, async function(req, res) {
  let account = req.params.account;
  let continuationToken = req.query.continuationToken || null;

  let blob = new azure.Blob({
    accountId: account,
    accessKey: this.azureAccounts[account],
  });

  let result = await blob.listContainers({marker: continuationToken});
  let data = {containers: result.containers.map(c => c.name)};
  if (result.nextMarker) {
    data.continuationToken = result.nextMarker;
  }
  return res.reply(data);
});

fast-azure-storage

Fast client library for azure storage services

MPL-2.0
Latest version published 11 months ago

Package Health Score

77 / 100
Full package analysis

Similar packages