Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diberry/1217 blob storage file upload content type 2 #12938

Merged
merged 7 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ async function upload() {

const file = document.getElementById("file").files[0];
await blockBlobClient.uploadBrowserData(file, {
maxSingleShotSize: 4 * 1024 * 1024
maxSingleShotSize: 4 * 1024 * 1024,
blobHTTPHeaders: { blobContentType: file.type } // set mimetype
});
}
40 changes: 32 additions & 8 deletions sdk/storage/storage-blob/src/Clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,9 @@ export class BlobClient extends StorageClient {
*
* @param {BlobHTTPHeaders} [blobHTTPHeaders] If no value provided, or no value provided for
* the specified blob HTTP headers, these blob HTTP
* headers without a value will be cleared.
* headers without a value will be cleared.
* A common header to set is `blobContentType`, * enabling the browser to provide functionality
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change line before *?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot - I'll fix it.

* based on file type.
* @param {BlobSetHTTPHeadersOptions} [options] Optional options to Blob Set HTTP Headers operation.
* @returns {Promise<BlobSetHTTPHeadersResponse>}
* @memberof BlobClient
Expand Down Expand Up @@ -2579,7 +2581,9 @@ export interface AppendBlobCreateOptions extends CommonOptions {
*/
conditions?: BlobRequestConditions;
/**
* HTTP headers to set when creating append blobs.
* HTTP headers to set when creating append blobs. A common header
* to set is `blobContentType`, enabling the browser to provide functionality
* based on file type.
*
* @type {BlobHTTPHeaders}
* @memberof AppendBlobCreateOptions
Expand Down Expand Up @@ -2634,7 +2638,9 @@ export interface AppendBlobCreateIfNotExistsOptions extends CommonOptions {
*/
abortSignal?: AbortSignalLike;
/**
* HTTP headers to set when creating append blobs.
* HTTP headers to set when creating append blobs. A common header to set is
* `blobContentType`, enabling the browser to provide functionality
* based on file type.
*
* @type {BlobHTTPHeaders}
* @memberof AppendBlobCreateIfNotExistsOptions
Expand Down Expand Up @@ -3309,7 +3315,9 @@ export interface BlockBlobUploadOptions extends CommonOptions {
*/
conditions?: BlobRequestConditions;
/**
* HTTP headers to set when uploading to a block blob.
* HTTP headers to set when uploading to a block blob. A common header to set is
* `blobContentType`, enabling the browser to provide functionality
* based on file type.
*
* @type {BlobHTTPHeaders}
* @memberof BlockBlobUploadOptions
Expand Down Expand Up @@ -3437,8 +3445,11 @@ export interface BlockBlobSyncUploadFromURLOptions extends CommonOptions {
*/
copySourceBlobProperties?: boolean;
/**
* HTTP headers to set when uploading to a block blob.
*
* HTTP headers to set when uploading to a block blob.
*
* A common header to set is `blobContentType`, enabling the browser to provide functionality
* based on file type.
*
* @type {BlobHTTPHeaders}
* @memberof BlockBlobSyncUploadFromURLOptions
*/
Expand Down Expand Up @@ -3917,6 +3928,9 @@ export interface BlockBlobUploadStreamOptions extends CommonOptions {

/**
* Blob HTTP Headers.
*
* A common header to set is `blobContentType`, enabling the
* browser to provide functionality based on file type.
*
* @type {BlobHTTPHeaders}
* @memberof BlockBlobUploadStreamOptions
Expand Down Expand Up @@ -4019,7 +4033,9 @@ export interface BlockBlobParallelUploadOptions extends CommonOptions {
onProgress?: (progress: TransferProgressEvent) => void;

/**
* Blob HTTP Headers.
* Blob HTTP Headers. A common header to set is
* `blobContentType`, enabling the browser to provide
* functionality based on file type.
*
* @type {BlobHTTPHeaders}
* @memberof BlockBlobParallelUploadOptions
Expand Down Expand Up @@ -4703,7 +4719,11 @@ export class BlockBlobClient extends BlobClient {
* {@link BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES}), this method will use 1 {@link upload} call to finish the upload.
* Otherwise, this method will call {@link stageBlock} to upload blocks, and finally call {@link commitBlockList}
* to commit the block list.
*
*
* A common {@link BlockBlobParallelUploadOptions.blobHTTPHeaders} option to set is
* `blobContentType`, enabling the browser to provide
* functionality based on file type.
*
* @export
* @param {Buffer | Blob | ArrayBuffer | ArrayBufferView} data Buffer(Node.js), Blob, ArrayBuffer or ArrayBufferView
* @param {BlockBlobParallelUploadOptions} [options]
Expand Down Expand Up @@ -4763,6 +4783,10 @@ export class BlockBlobClient extends BlobClient {
* Otherwise, this method will call {@link stageBlock} to upload blocks, and finally call
* {@link commitBlockList} to commit the block list.
*
* A common {@link BlockBlobParallelUploadOptions.blobHTTPHeaders} option to set is
* `blobContentType`, enabling the browser to provide
* functionality based on file type.
*
* @deprecated Use {@link uploadData} instead.
*
* @export
Expand Down