1 | // Copyright (c) Microsoft Corporation.
|
2 | // Licensed under the MIT license.
|
3 | import { isNode } from "@azure/core-http";
|
4 | import { BlobQuickQueryStream } from "./utils/BlobQuickQueryStream";
|
5 | /**
|
6 | * ONLY AVAILABLE IN NODE.JS RUNTIME.
|
7 | *
|
8 | * BlobQueryResponse implements BlobDownloadResponseModel interface, and in Node.js runtime it will
|
9 | * parse avor data returned by blob query.
|
10 | */
|
11 | export class BlobQueryResponse {
|
12 | /**
|
13 | * Creates an instance of BlobQueryResponse.
|
14 | *
|
15 | * @param originalResponse -
|
16 | * @param options -
|
17 | */
|
18 | constructor(originalResponse, options = {}) {
|
19 | this.originalResponse = originalResponse;
|
20 | this.blobDownloadStream = new BlobQuickQueryStream(this.originalResponse.readableStreamBody, options);
|
21 | }
|
22 | /**
|
23 | * Indicates that the service supports
|
24 | * requests for partial file content.
|
25 | *
|
26 | * @readonly
|
27 | */
|
28 | get acceptRanges() {
|
29 | return this.originalResponse.acceptRanges;
|
30 | }
|
31 | /**
|
32 | * Returns if it was previously specified
|
33 | * for the file.
|
34 | *
|
35 | * @readonly
|
36 | */
|
37 | get cacheControl() {
|
38 | return this.originalResponse.cacheControl;
|
39 | }
|
40 | /**
|
41 | * Returns the value that was specified
|
42 | * for the 'x-ms-content-disposition' header and specifies how to process the
|
43 | * response.
|
44 | *
|
45 | * @readonly
|
46 | */
|
47 | get contentDisposition() {
|
48 | return this.originalResponse.contentDisposition;
|
49 | }
|
50 | /**
|
51 | * Returns the value that was specified
|
52 | * for the Content-Encoding request header.
|
53 | *
|
54 | * @readonly
|
55 | */
|
56 | get contentEncoding() {
|
57 | return this.originalResponse.contentEncoding;
|
58 | }
|
59 | /**
|
60 | * Returns the value that was specified
|
61 | * for the Content-Language request header.
|
62 | *
|
63 | * @readonly
|
64 | */
|
65 | get contentLanguage() {
|
66 | return this.originalResponse.contentLanguage;
|
67 | }
|
68 | /**
|
69 | * The current sequence number for a
|
70 | * page blob. This header is not returned for block blobs or append blobs.
|
71 | *
|
72 | * @readonly
|
73 | */
|
74 | get blobSequenceNumber() {
|
75 | return this.originalResponse.blobSequenceNumber;
|
76 | }
|
77 | /**
|
78 | * The blob's type. Possible values include:
|
79 | * 'BlockBlob', 'PageBlob', 'AppendBlob'.
|
80 | *
|
81 | * @readonly
|
82 | */
|
83 | get blobType() {
|
84 | return this.originalResponse.blobType;
|
85 | }
|
86 | /**
|
87 | * The number of bytes present in the
|
88 | * response body.
|
89 | *
|
90 | * @readonly
|
91 | */
|
92 | get contentLength() {
|
93 | return this.originalResponse.contentLength;
|
94 | }
|
95 | /**
|
96 | * If the file has an MD5 hash and the
|
97 | * request is to read the full file, this response header is returned so that
|
98 | * the client can check for message content integrity. If the request is to
|
99 | * read a specified range and the 'x-ms-range-get-content-md5' is set to
|
100 | * true, then the request returns an MD5 hash for the range, as long as the
|
101 | * range size is less than or equal to 4 MB. If neither of these sets of
|
102 | * conditions is true, then no value is returned for the 'Content-MD5'
|
103 | * header.
|
104 | *
|
105 | * @readonly
|
106 | */
|
107 | get contentMD5() {
|
108 | return this.originalResponse.contentMD5;
|
109 | }
|
110 | /**
|
111 | * Indicates the range of bytes returned if
|
112 | * the client requested a subset of the file by setting the Range request
|
113 | * header.
|
114 | *
|
115 | * @readonly
|
116 | */
|
117 | get contentRange() {
|
118 | return this.originalResponse.contentRange;
|
119 | }
|
120 | /**
|
121 | * The content type specified for the file.
|
122 | * The default content type is 'application/octet-stream'
|
123 | *
|
124 | * @readonly
|
125 | */
|
126 | get contentType() {
|
127 | return this.originalResponse.contentType;
|
128 | }
|
129 | /**
|
130 | * Conclusion time of the last attempted
|
131 | * Copy File operation where this file was the destination file. This value
|
132 | * can specify the time of a completed, aborted, or failed copy attempt.
|
133 | *
|
134 | * @readonly
|
135 | */
|
136 | get copyCompletedOn() {
|
137 | return undefined;
|
138 | }
|
139 | /**
|
140 | * String identifier for the last attempted Copy
|
141 | * File operation where this file was the destination file.
|
142 | *
|
143 | * @readonly
|
144 | */
|
145 | get copyId() {
|
146 | return this.originalResponse.copyId;
|
147 | }
|
148 | /**
|
149 | * Contains the number of bytes copied and
|
150 | * the total bytes in the source in the last attempted Copy File operation
|
151 | * where this file was the destination file. Can show between 0 and
|
152 | * Content-Length bytes copied.
|
153 | *
|
154 | * @readonly
|
155 | */
|
156 | get copyProgress() {
|
157 | return this.originalResponse.copyProgress;
|
158 | }
|
159 | /**
|
160 | * URL up to 2KB in length that specifies the
|
161 | * source file used in the last attempted Copy File operation where this file
|
162 | * was the destination file.
|
163 | *
|
164 | * @readonly
|
165 | */
|
166 | get copySource() {
|
167 | return this.originalResponse.copySource;
|
168 | }
|
169 | /**
|
170 | * State of the copy operation
|
171 | * identified by 'x-ms-copy-id'. Possible values include: 'pending',
|
172 | * 'success', 'aborted', 'failed'
|
173 | *
|
174 | * @readonly
|
175 | */
|
176 | get copyStatus() {
|
177 | return this.originalResponse.copyStatus;
|
178 | }
|
179 | /**
|
180 | * Only appears when
|
181 | * x-ms-copy-status is failed or pending. Describes cause of fatal or
|
182 | * non-fatal copy operation failure.
|
183 | *
|
184 | * @readonly
|
185 | */
|
186 | get copyStatusDescription() {
|
187 | return this.originalResponse.copyStatusDescription;
|
188 | }
|
189 | /**
|
190 | * When a blob is leased,
|
191 | * specifies whether the lease is of infinite or fixed duration. Possible
|
192 | * values include: 'infinite', 'fixed'.
|
193 | *
|
194 | * @readonly
|
195 | */
|
196 | get leaseDuration() {
|
197 | return this.originalResponse.leaseDuration;
|
198 | }
|
199 | /**
|
200 | * Lease state of the blob. Possible
|
201 | * values include: 'available', 'leased', 'expired', 'breaking', 'broken'.
|
202 | *
|
203 | * @readonly
|
204 | */
|
205 | get leaseState() {
|
206 | return this.originalResponse.leaseState;
|
207 | }
|
208 | /**
|
209 | * The current lease status of the
|
210 | * blob. Possible values include: 'locked', 'unlocked'.
|
211 | *
|
212 | * @readonly
|
213 | */
|
214 | get leaseStatus() {
|
215 | return this.originalResponse.leaseStatus;
|
216 | }
|
217 | /**
|
218 | * A UTC date/time value generated by the service that
|
219 | * indicates the time at which the response was initiated.
|
220 | *
|
221 | * @readonly
|
222 | */
|
223 | get date() {
|
224 | return this.originalResponse.date;
|
225 | }
|
226 | /**
|
227 | * The number of committed blocks
|
228 | * present in the blob. This header is returned only for append blobs.
|
229 | *
|
230 | * @readonly
|
231 | */
|
232 | get blobCommittedBlockCount() {
|
233 | return this.originalResponse.blobCommittedBlockCount;
|
234 | }
|
235 | /**
|
236 | * The ETag contains a value that you can use to
|
237 | * perform operations conditionally, in quotes.
|
238 | *
|
239 | * @readonly
|
240 | */
|
241 | get etag() {
|
242 | return this.originalResponse.etag;
|
243 | }
|
244 | /**
|
245 | * The error code.
|
246 | *
|
247 | * @readonly
|
248 | */
|
249 | get errorCode() {
|
250 | return this.originalResponse.errorCode;
|
251 | }
|
252 | /**
|
253 | * The value of this header is set to
|
254 | * true if the file data and application metadata are completely encrypted
|
255 | * using the specified algorithm. Otherwise, the value is set to false (when
|
256 | * the file is unencrypted, or if only parts of the file/application metadata
|
257 | * are encrypted).
|
258 | *
|
259 | * @readonly
|
260 | */
|
261 | get isServerEncrypted() {
|
262 | return this.originalResponse.isServerEncrypted;
|
263 | }
|
264 | /**
|
265 | * If the blob has a MD5 hash, and if
|
266 | * request contains range header (Range or x-ms-range), this response header
|
267 | * is returned with the value of the whole blob's MD5 value. This value may
|
268 | * or may not be equal to the value returned in Content-MD5 header, with the
|
269 | * latter calculated from the requested range.
|
270 | *
|
271 | * @readonly
|
272 | */
|
273 | get blobContentMD5() {
|
274 | return this.originalResponse.blobContentMD5;
|
275 | }
|
276 | /**
|
277 | * Returns the date and time the file was last
|
278 | * modified. Any operation that modifies the file or its properties updates
|
279 | * the last modified time.
|
280 | *
|
281 | * @readonly
|
282 | */
|
283 | get lastModified() {
|
284 | return this.originalResponse.lastModified;
|
285 | }
|
286 | /**
|
287 | * A name-value pair
|
288 | * to associate with a file storage object.
|
289 | *
|
290 | * @readonly
|
291 | */
|
292 | get metadata() {
|
293 | return this.originalResponse.metadata;
|
294 | }
|
295 | /**
|
296 | * This header uniquely identifies the request
|
297 | * that was made and can be used for troubleshooting the request.
|
298 | *
|
299 | * @readonly
|
300 | */
|
301 | get requestId() {
|
302 | return this.originalResponse.requestId;
|
303 | }
|
304 | /**
|
305 | * If a client request id header is sent in the request, this header will be present in the
|
306 | * response with the same value.
|
307 | *
|
308 | * @readonly
|
309 | */
|
310 | get clientRequestId() {
|
311 | return this.originalResponse.clientRequestId;
|
312 | }
|
313 | /**
|
314 | * Indicates the version of the File service used
|
315 | * to execute the request.
|
316 | *
|
317 | * @readonly
|
318 | */
|
319 | get version() {
|
320 | return this.originalResponse.version;
|
321 | }
|
322 | /**
|
323 | * The SHA-256 hash of the encryption key used to encrypt the blob. This value is only returned
|
324 | * when the blob was encrypted with a customer-provided key.
|
325 | *
|
326 | * @readonly
|
327 | */
|
328 | get encryptionKeySha256() {
|
329 | return this.originalResponse.encryptionKeySha256;
|
330 | }
|
331 | /**
|
332 | * If the request is to read a specified range and the x-ms-range-get-content-crc64 is set to
|
333 | * true, then the request returns a crc64 for the range, as long as the range size is less than
|
334 | * or equal to 4 MB. If both x-ms-range-get-content-crc64 & x-ms-range-get-content-md5 is
|
335 | * specified in the same request, it will fail with 400(Bad Request)
|
336 | */
|
337 | get contentCrc64() {
|
338 | return this.originalResponse.contentCrc64;
|
339 | }
|
340 | /**
|
341 | * The response body as a browser Blob.
|
342 | * Always undefined in node.js.
|
343 | *
|
344 | * @readonly
|
345 | */
|
346 | get blobBody() {
|
347 | return undefined;
|
348 | }
|
349 | /**
|
350 | * The response body as a node.js Readable stream.
|
351 | * Always undefined in the browser.
|
352 | *
|
353 | * It will parse avor data returned by blob query.
|
354 | *
|
355 | * @readonly
|
356 | */
|
357 | get readableStreamBody() {
|
358 | return isNode ? this.blobDownloadStream : undefined;
|
359 | }
|
360 | /**
|
361 | * The HTTP response.
|
362 | */
|
363 | get _response() {
|
364 | return this.originalResponse._response;
|
365 | }
|
366 | }
|
367 | //# sourceMappingURL=BlobQueryResponse.js.map |
\ | No newline at end of file |