Azure/azure-storage-js

how to track progress with uploadBrowserDataToBlockBlob

Closed this issue · 2 comments

Which service(blob, file, queue, table) does this issue concern?

blob

Which version of the SDK was used?

10.3.0

What's the Node.js/Browser version?

What problem was encountered?

How do I use the progress call back passed to uploadBrowserDataToBlockBlob

      response = await Azure.uploadBrowserDataToBlockBlob(Azure.Aborter.none, file, blockBlobURL, {
        maxSingleShotSize: 4 * 1024 * 1024,
        progress: (progressEvent: TransferProgressEvent) => {
          console.log(progressEvent);
        }
      });

I just get an object with loadedBytes which seems to be the full amount of the block.

Is there a way I can track the progress with this?

What was your answer to this?

@MonteKrysto if you look at the definition of uploadBrowserDataToBlockBlob

export declare function uploadBrowserDataToBlockBlob(aborter: Aborter, browserData: Blob | ArrayBuffer | ArrayBufferView, blockBlobURL: BlockBlobURL, options?: IUploadToBlockBlobOptions): Promise<BlobUploadCommonResponse>;

It takes an options argument:

export interface IUploadToBlockBlobOptions {
    /**
     * Destination block blob size in bytes.
     *
     * @type {number}
     * @memberof IUploadToBlockBlobOptions
     */
    blockSize?: number;
    /**
     * Blob size threshold in bytes to start concurrency uploading.
     * Default value is 256MB, blob size less than this option will
     * be uploaded via one I/O operation without concurrency.
     * You can customize a value less equal than the default value.
     *
     * @type {number}
     * @memberof IUploadToBlockBlobOptions
     */
    maxSingleShotSize?: number;
    /**
     * Progress updater.
     *
     * @memberof IUploadToBlockBlobOptions
     */
    progress?: (progress: TransferProgressEvent) => void;
    /**
     * Blob HTTP Headers.
     *
     * @type {IBlobHTTPHeaders}
     * @memberof IUploadToBlockBlobOptions
     */
    blobHTTPHeaders?: Models.BlobHTTPHeaders;
    /**
     * Metadata of block blob.
     *
     * @type {{ [propertyName: string]: string }}
     * @memberof IUploadToBlockBlobOptions
     */
    metadata?: {
        [propertyName: string]: string;
    };
    /**
     * Access conditions headers.
     *
     * @type {IBlobAccessConditions}
     * @memberof IUploadToBlockBlobOptions
     */
    blobAccessConditions?: IBlobAccessConditions;
    /**
     * Concurrency of parallel uploading. Must be >= 0.
     *
     * @type {number}
     * @memberof IUploadToBlockBlobOptions
     */
    parallelism?: number;
}

You can pass a progress function that you can use.