1 |
|
2 |
|
3 | import { StorageClientContext } from "./generated/src/storageClientContext";
|
4 | import { escapeURLPath, getURLScheme, iEqual, getAccountNameFromUrl } from "./utils/utils.common";
|
5 | import { AnonymousCredential } from "./credentials/AnonymousCredential";
|
6 | import { StorageSharedKeyCredential } from "./credentials/StorageSharedKeyCredential";
|
7 | import { isTokenCredential, isNode } from "@azure/core-http";
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export class StorageClient {
|
13 | |
14 |
|
15 |
|
16 |
|
17 |
|
18 | constructor(url, pipeline) {
|
19 |
|
20 | this.url = escapeURLPath(url);
|
21 | this.accountName = getAccountNameFromUrl(url);
|
22 | this.pipeline = pipeline;
|
23 | this.storageClientContext = new StorageClientContext(this.url, pipeline.toServiceClientOptions());
|
24 | this.isHttps = iEqual(getURLScheme(this.url) || "", "https");
|
25 | this.credential = new AnonymousCredential();
|
26 | for (const factory of this.pipeline.factories) {
|
27 | if ((isNode && factory instanceof StorageSharedKeyCredential) ||
|
28 | factory instanceof AnonymousCredential) {
|
29 | this.credential = factory;
|
30 | }
|
31 | else if (isTokenCredential(factory.credential)) {
|
32 |
|
33 |
|
34 | this.credential = factory.credential;
|
35 | }
|
36 | }
|
37 |
|
38 | const storageClientContext = this.storageClientContext;
|
39 | storageClientContext.requestContentType = undefined;
|
40 | }
|
41 | }
|
42 |
|
\ | No newline at end of file |