How to use the azure-storage.createBlobServiceWithSas 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 Azure-Samples / storage-blob-node-getting-started / advanced.js View on Github external
expiryDate.setMinutes(expiryDate.getMinutes() + 30);

    var sharedAccessPolicy = {
      AccessPolicy: {
        Permissions: storage.BlobUtilities.SharedAccessPermissions.READ +
        storage.BlobUtilities.SharedAccessPermissions.WRITE +
        storage.BlobUtilities.SharedAccessPermissions.DELETE +
        storage.BlobUtilities.SharedAccessPermissions.LIST,
        Expiry: expiryDate
      }
    };

    var sas = blobService.generateSharedAccessSignature(containerName, null, sharedAccessPolicy);

    var sharedBlobService = storage.createBlobServiceWithSas(blobService.host, sas);

    console.log('3. Creating blob with Shared Access Signature');
    sharedBlobService.createBlockBlobFromText(containerName, blobName, 'test data', function (error) {
      if (error) return callback(error);

      console.log('4. Listing blobs in container with Shared Access Signature');
      listBlobs(sharedBlobService, containerName, null, null, null, function (error, blobs) {
        if (error) return callback(error);

        console.log('5. Deleting blob with Shared Access Signature');
        sharedBlobService.deleteBlob(containerName, blobName, function (error) {
          if (error) return callback(error);

          console.log('6. Deleting container');
          blobService.deleteContainer(containerName, function (error) {
            return callback(error);
github Azure / BatchExplorer / src / app / services / storage / storage-blob.service.ts View on Github external
public uploadToSasUrl(sasUrl: string, filePath: string): Observable {
        const subject = new AsyncSubject();

        const { accountUrl, sasToken, container, blob } = this._parseSasUrl(sasUrl);
        const service = createBlobServiceWithSas(accountUrl, sasToken);
        service.createBlockBlobFromLocalFile(container, blob, filePath,
            (error: any, result: BlobService.BlobResult) => {
                this.zone.run(() => {

                    if (error) {
                        subject.error(ServerError.fromStorage(error));
                        subject.complete();
                    }
                    subject.next(result);
                    subject.complete();
                });
            });

        return subject.asObservable();
    }
github Azure / azure-kusto-node / azure-kusto-ingest / source / ingestClient.js View on Github external
return this.resourceManager.getContainers((err, containers) => {
            if (err) return callback(err);

            const containerDetails = containers[Math.floor(Math.random() * containers.length)];
            const blobService = azureStorage.createBlobServiceWithSas(
                containerDetails.toURI({ withSas: false, withObjectName: false }),
                containerDetails.sas
            );

            const blobName = `${props.database}__${props.table}__${uuidv4()}`;
            const writeStream = blobService.createWriteStreamToBlockBlob(containerDetails.objectName, blobName, (err) => {
                if (err) return callback(err);

                const blobUri = `${containerDetails.toURI({ withSas: false })}/${blobName}?${containerDetails.sas}`;
                return this.ingestFromBlob(new BlobDescriptor(blobUri, descriptor.size), props, callback);
            });

            descriptor.pipe(writeStream);
        });
    }
github Azure / BatchExplorer / app / services / storage / storage-blob.service.ts View on Github external
public uploadToSasUrl(sasUrl: string, filePath: string): Observable {
        const subject = new AsyncSubject();

        const { accountUrl, sasToken, container, blob } = this._parseSasUrl(sasUrl);
        const service = createBlobServiceWithSas(accountUrl, sasToken);
        service.createBlockBlobFromLocalFile(container, blob, filePath,
            (error: any, result: BlobService.BlobResult) => {
                this.zone.run(() => {

                    if (error) {
                        subject.error(ServerError.fromStorage(error));
                        subject.complete();
                    }
                    subject.next(result);
                    subject.complete();
                });
            });

        return subject.asObservable();
    }
github Azure / azure-kusto-node / azure-kusto-ingest / source / ingestClient.js View on Github external
this.resourceManager.getContainers((err, containers) => {
                if (err) return callback(err);
                const containerDetails = containers[Math.floor(Math.random() * containers.length)];
                const blobService = azureStorage.createBlobServiceWithSas(containerDetails.toURI({
                    withObjectName: false,
                    withSas: false
                }), containerDetails.sas);

                blobService.createBlockBlobFromLocalFile(containerDetails.objectName, blobName, fileToUpload, (err) => {
                    if (err) return callback(err);
                    const blobUri = `${containerDetails.toURI({ withSas: false })}/${blobName}?${containerDetails.sas}`;
                    return this.ingestFromBlob(new BlobDescriptor(blobUri, descriptor.size, descriptor.sourceId), props, callback);
                });
            });