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 all 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 @@ -103,7 +103,8 @@ async function upload() {
);

const file = document.getElementById("file").files[0];
await blockBlobClient.uploadData(file, {
maxSingleShotSize: 4 * 1024 * 1024
await blockBlobClient.uploadBrowserData(file, {
maxSingleShotSize: 4 * 1024 * 1024,
blobHTTPHeaders: { blobContentType: file.type } // set mimetype
});
}
39 changes: 35 additions & 4 deletions sdk/storage/storage-blob/src/Clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@ export class BlobClient extends StorageClient {
* @param 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.
* A common header to set is `blobContentType`
* enabling the browser to provide functionality
* based on file type.
* @param options - Optional options to Blob Set HTTP Headers operation.
*/
public async setHTTPHeaders(
Expand Down Expand Up @@ -2135,7 +2138,10 @@ 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.
*
*/
blobHTTPHeaders?: BlobHTTPHeaders;
/**
Expand Down Expand Up @@ -2169,7 +2175,10 @@ 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.
*
*/
blobHTTPHeaders?: BlobHTTPHeaders;
/**
Expand Down Expand Up @@ -2731,7 +2740,10 @@ 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.
*
*/
blobHTTPHeaders?: BlobHTTPHeaders;
/**
Expand Down Expand Up @@ -2814,6 +2826,10 @@ export interface BlockBlobSyncUploadFromURLOptions extends CommonOptions {
copySourceBlobProperties?: boolean;
/**
* 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.
*
*/
blobHTTPHeaders?: BlobHTTPHeaders;
/**
Expand Down Expand Up @@ -3115,6 +3131,10 @@ 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.
*
*/
blobHTTPHeaders?: BlobHTTPHeaders;

Expand Down Expand Up @@ -3181,7 +3201,10 @@ 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.
*
*/
blobHTTPHeaders?: BlobHTTPHeaders;

Expand Down Expand Up @@ -3809,6 +3832,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.
*
* @param data - Buffer(Node.js), Blob, ArrayBuffer or ArrayBufferView
* @param options -
*/
Expand Down Expand Up @@ -3862,6 +3889,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.
*
* @param browserData - Blob, File, ArrayBuffer or ArrayBufferView
Expand Down