-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check both Content-MD5 and x-ms-blob-content-md5
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { BaseRequestPolicy, WebResource } from "@azure/storage-blob"; | ||
|
||
// Create a policy factory with create() method provided | ||
// In TypeScript, following factory class needs to implement Azure.RequestPolicyFactory type | ||
export default class CustomHeaderPolicyFactory { | ||
// Constructor to accept parameters | ||
private key: string; | ||
private value: string; | ||
|
||
constructor(key: string, value: string) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
create(nextPolicy: any, options: any) { | ||
return new CustomHeaderPolicy(nextPolicy, options, this.key, this.value); | ||
} | ||
} | ||
|
||
// Create a policy by extending from Azure.BaseRequestPolicy | ||
class CustomHeaderPolicy extends BaseRequestPolicy { | ||
private key: string; | ||
private value: string; | ||
|
||
constructor(nextPolicy: any, options: any, key: string, value: string) { | ||
super(nextPolicy, options); | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
// Customize HTTP requests and responses by overriding sendRequest | ||
// Parameter request is Azure.WebResource type | ||
async sendRequest(request: WebResource) { | ||
request.headers.set(this.key, this.value); | ||
|
||
return await this._nextPolicy.sendRequest(request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters