@eluvio/elv-client-js 4.2.10 → 4.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +1 -1
- package/dist/ElvClient-node-min.js +1 -1
- package/dist/ElvFrameClient-min.js +1 -1
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +1 -1
- package/dist/src/AuthorizationClient.js +723 -710
- package/dist/src/ContentObjectAudit.js +56 -56
- package/dist/src/ContentObjectVerification.js +281 -0
- package/dist/src/Crypto.js +85 -85
- package/dist/src/ElvClient.js +500 -530
- package/dist/src/ElvWallet.js +28 -30
- package/dist/src/EthClient.js +311 -311
- package/dist/src/FrameClient.js +64 -63
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +2 -1
- package/dist/src/PermissionsClient.js +487 -499
- package/dist/src/RemoteSigner.js +163 -114
- package/dist/src/UserProfileClient.js +374 -392
- package/dist/src/Utils.js +66 -69
- package/dist/src/Validation.js +10 -10
- package/dist/src/client/ABRPublishing.js +238 -238
- package/dist/src/client/AccessGroups.js +474 -477
- package/dist/src/client/ContentAccess.js +1709 -1705
- package/dist/src/client/ContentManagement.js +871 -871
- package/dist/src/client/Contracts.js +578 -575
- package/dist/src/client/Files.js +684 -700
- package/dist/src/client/LiveConf.js +6 -1
- package/dist/src/client/LiveStream.js +686 -723
- package/dist/src/client/NFT.js +14 -14
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +60 -53
- package/dist/src/walletClient/ClientMethods.js +951 -977
- package/dist/src/walletClient/Notifications.js +14 -14
- package/dist/src/walletClient/Profile.js +66 -66
- package/dist/src/walletClient/Utils.js +15 -15
- package/dist/src/walletClient/index.js +581 -579
- package/package.json +1 -1
- package/src/client/LiveConf.js +5 -1
- package/src/client/LiveStream.js +9 -39
package/dist/src/client/Files.js
CHANGED
|
@@ -40,9 +40,9 @@ var _require = require("../Validation"),
|
|
|
40
40
|
* @param {string=} writeToken - Write token of a draft (incompatible with versionHash)
|
|
41
41
|
*/
|
|
42
42
|
exports.ListFiles = /*#__PURE__*/function () {
|
|
43
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
44
|
-
var libraryId, objectId, _ref$path, path, versionHash, writeToken, urlPath
|
|
45
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
43
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
44
|
+
var libraryId, objectId, _ref$path, path, versionHash, writeToken, urlPath;
|
|
45
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
46
46
|
while (1) switch (_context.prev = _context.next) {
|
|
47
47
|
case 0:
|
|
48
48
|
libraryId = _ref.libraryId, objectId = _ref.objectId, _ref$path = _ref.path, path = _ref$path === void 0 ? "" : _ref$path, versionHash = _ref.versionHash, writeToken = _ref.writeToken;
|
|
@@ -56,23 +56,23 @@ exports.ListFiles = /*#__PURE__*/function () {
|
|
|
56
56
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
57
57
|
}
|
|
58
58
|
urlPath = UrlJoin("q", writeToken || versionHash || objectId, "files_list", path);
|
|
59
|
-
|
|
60
|
-
_context.next =
|
|
59
|
+
_context.t0 = this.HttpClient;
|
|
60
|
+
_context.next = 7;
|
|
61
61
|
return this.authClient.AuthorizationHeader({
|
|
62
62
|
libraryId: libraryId,
|
|
63
63
|
objectId: objectId,
|
|
64
64
|
versionHash: versionHash
|
|
65
65
|
});
|
|
66
|
-
case
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
headers:
|
|
66
|
+
case 7:
|
|
67
|
+
_context.t1 = _context.sent;
|
|
68
|
+
_context.t2 = urlPath;
|
|
69
|
+
_context.t3 = {
|
|
70
|
+
headers: _context.t1,
|
|
71
71
|
method: "GET",
|
|
72
|
-
path:
|
|
72
|
+
path: _context.t2
|
|
73
73
|
};
|
|
74
|
-
return _context.abrupt("return",
|
|
75
|
-
case
|
|
74
|
+
return _context.abrupt("return", _context.t0.RequestJsonBody.call(_context.t0, _context.t3));
|
|
75
|
+
case 11:
|
|
76
76
|
case "end":
|
|
77
77
|
return _context.stop();
|
|
78
78
|
}
|
|
@@ -118,9 +118,9 @@ exports.ListFiles = /*#__PURE__*/function () {
|
|
|
118
118
|
* - Arguments (reference): { done: boolean, uploadedFiles: number, totalFiles: number }
|
|
119
119
|
*/
|
|
120
120
|
exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
121
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
121
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
122
122
|
var libraryId, objectId, writeToken, region, bucket, fileInfo, accessKey, secret, signedUrl, _ref3$encryption, encryption, _ref3$copy, copy, callback, s3prefixRegex, i, fileSourcePath, s3prefixMatch, bucketName, encryption_key, conk, cloudCredentials, defaults, ops, _yield$this$CreateFil, id, status, done, progress, _progress;
|
|
123
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
123
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
124
124
|
while (1) switch (_context2.prev = _context2.next) {
|
|
125
125
|
case 0:
|
|
126
126
|
libraryId = _ref3.libraryId, objectId = _ref3.objectId, writeToken = _ref3.writeToken, region = _ref3.region, bucket = _ref3.bucket, fileInfo = _ref3.fileInfo, accessKey = _ref3.accessKey, secret = _ref3.secret, signedUrl = _ref3.signedUrl, _ref3$encryption = _ref3.encryption, encryption = _ref3$encryption === void 0 ? "none" : _ref3$encryption, _ref3$copy = _ref3.copy, copy = _ref3$copy === void 0 ? false : _ref3$copy, callback = _ref3.callback;
|
|
@@ -132,53 +132,53 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
132
132
|
s3prefixRegex = /^s3:\/\/([^/]+)\//i; // for matching and extracting bucket name when full s3:// path is specified
|
|
133
133
|
// if fileInfo source paths start with s3://bucketName/, check against bucket arg passed in, and strip
|
|
134
134
|
i = 0;
|
|
135
|
-
case
|
|
135
|
+
case 5:
|
|
136
136
|
if (!(i < fileInfo.length)) {
|
|
137
|
-
_context2.next =
|
|
137
|
+
_context2.next = 18;
|
|
138
138
|
break;
|
|
139
139
|
}
|
|
140
140
|
fileSourcePath = fileInfo[i].source;
|
|
141
141
|
s3prefixMatch = s3prefixRegex.exec(fileSourcePath);
|
|
142
142
|
if (!s3prefixMatch) {
|
|
143
|
-
_context2.next =
|
|
143
|
+
_context2.next = 15;
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
146
|
bucketName = s3prefixMatch[1];
|
|
147
147
|
if (!(bucketName !== bucket)) {
|
|
148
|
-
_context2.next =
|
|
148
|
+
_context2.next = 14;
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
151
|
throw Error("Full S3 file path \"" + fileSourcePath + "\" specified, but does not match provided bucket name '" + bucket + "'");
|
|
152
|
-
case
|
|
152
|
+
case 14:
|
|
153
153
|
// strip prefix
|
|
154
154
|
fileInfo[i].source = fileSourcePath.replace(s3prefixRegex, "");
|
|
155
|
-
case
|
|
155
|
+
case 15:
|
|
156
156
|
i++;
|
|
157
|
-
_context2.next =
|
|
157
|
+
_context2.next = 5;
|
|
158
158
|
break;
|
|
159
|
-
case
|
|
159
|
+
case 18:
|
|
160
160
|
if (copy) {
|
|
161
161
|
this.Log("Copying files from S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
162
162
|
} else {
|
|
163
163
|
this.Log("Adding links to files in S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
164
164
|
}
|
|
165
165
|
if (!(encryption === "cgck")) {
|
|
166
|
-
_context2.next =
|
|
166
|
+
_context2.next = 25;
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
|
-
_context2.next =
|
|
169
|
+
_context2.next = 22;
|
|
170
170
|
return this.EncryptionConk({
|
|
171
171
|
libraryId: libraryId,
|
|
172
172
|
objectId: objectId,
|
|
173
173
|
writeToken: writeToken
|
|
174
174
|
});
|
|
175
|
-
case
|
|
175
|
+
case 22:
|
|
176
176
|
conk = _context2.sent;
|
|
177
177
|
conk = _objectSpread(_objectSpread({}, conk), {}, {
|
|
178
178
|
secret_key: ""
|
|
179
179
|
});
|
|
180
180
|
encryption_key = "kp__".concat(this.utils.B58(Buffer.from(JSON.stringify(conk))));
|
|
181
|
-
case
|
|
181
|
+
case 25:
|
|
182
182
|
cloudCredentials = {
|
|
183
183
|
access_key_id: accessKey,
|
|
184
184
|
secret_access_key: secret
|
|
@@ -224,7 +224,7 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
}); // eslint-disable-next-line no-unused-vars
|
|
227
|
-
_context2.next =
|
|
227
|
+
_context2.next = 31;
|
|
228
228
|
return this.CreateFileUploadJob({
|
|
229
229
|
libraryId: libraryId,
|
|
230
230
|
objectId: objectId,
|
|
@@ -232,47 +232,47 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
232
232
|
ops: ops,
|
|
233
233
|
defaults: defaults
|
|
234
234
|
});
|
|
235
|
-
case
|
|
235
|
+
case 31:
|
|
236
236
|
_yield$this$CreateFil = _context2.sent;
|
|
237
237
|
id = _yield$this$CreateFil.id;
|
|
238
|
-
case
|
|
238
|
+
case 33:
|
|
239
239
|
if (!true) {
|
|
240
|
-
_context2.next =
|
|
240
|
+
_context2.next = 56;
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
|
-
_context2.next =
|
|
243
|
+
_context2.next = 36;
|
|
244
244
|
return new Promise(function (resolve) {
|
|
245
245
|
return setTimeout(resolve, 1000);
|
|
246
246
|
});
|
|
247
|
-
case
|
|
248
|
-
_context2.next =
|
|
247
|
+
case 36:
|
|
248
|
+
_context2.next = 38;
|
|
249
249
|
return this.UploadStatus({
|
|
250
250
|
libraryId: libraryId,
|
|
251
251
|
objectId: objectId,
|
|
252
252
|
writeToken: writeToken,
|
|
253
253
|
uploadId: id
|
|
254
254
|
});
|
|
255
|
-
case
|
|
255
|
+
case 38:
|
|
256
256
|
status = _context2.sent;
|
|
257
257
|
if (!(status.errors && status.errors.length > 1)) {
|
|
258
|
-
_context2.next =
|
|
258
|
+
_context2.next = 43;
|
|
259
259
|
break;
|
|
260
260
|
}
|
|
261
261
|
throw status.errors.join("\n");
|
|
262
|
-
case
|
|
262
|
+
case 43:
|
|
263
263
|
if (!status.error) {
|
|
264
|
-
_context2.next =
|
|
264
|
+
_context2.next = 48;
|
|
265
265
|
break;
|
|
266
266
|
}
|
|
267
267
|
this.Log("S3 file upload failed:\n".concat(JSON.stringify(status, null, 2)));
|
|
268
268
|
throw status.error;
|
|
269
|
-
case
|
|
269
|
+
case 48:
|
|
270
270
|
if (!(status.status.toLowerCase() === "failed")) {
|
|
271
|
-
_context2.next =
|
|
271
|
+
_context2.next = 50;
|
|
272
272
|
break;
|
|
273
273
|
}
|
|
274
274
|
throw "File upload failed";
|
|
275
|
-
case
|
|
275
|
+
case 50:
|
|
276
276
|
done = false;
|
|
277
277
|
if (copy) {
|
|
278
278
|
done = status.ingest_copy.done;
|
|
@@ -299,14 +299,14 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
if (!done) {
|
|
302
|
-
_context2.next =
|
|
302
|
+
_context2.next = 54;
|
|
303
303
|
break;
|
|
304
304
|
}
|
|
305
|
-
return _context2.abrupt("
|
|
306
|
-
case
|
|
307
|
-
_context2.next =
|
|
305
|
+
return _context2.abrupt("break", 56);
|
|
306
|
+
case 54:
|
|
307
|
+
_context2.next = 33;
|
|
308
308
|
break;
|
|
309
|
-
case
|
|
309
|
+
case 56:
|
|
310
310
|
case "end":
|
|
311
311
|
return _context2.stop();
|
|
312
312
|
}
|
|
@@ -344,10 +344,10 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
344
344
|
* - Format: {"filename1": {uploaded: number, total: number}, ...}
|
|
345
345
|
*/
|
|
346
346
|
exports.UploadFiles = /*#__PURE__*/function () {
|
|
347
|
-
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref5) {
|
|
347
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref5) {
|
|
348
348
|
var _this = this;
|
|
349
349
|
var libraryId, objectId, writeToken, fileInfo, _ref5$encryption, encryption, callback, conk, progress, fileDataMap, originalFileInfo, i, entry, _yield$this$CreateFil2, id, jobs, bufferSize, jobSpecs, prepared, uploaded, PrepareJobs, UploadJob, rateTestJobs, rates, j, start, elapsed, size, averageRate, concurrentUploads;
|
|
350
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
350
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context7) {
|
|
351
351
|
while (1) switch (_context7.prev = _context7.next) {
|
|
352
352
|
case 0:
|
|
353
353
|
libraryId = _ref5.libraryId, objectId = _ref5.objectId, writeToken = _ref5.writeToken, fileInfo = _ref5.fileInfo, _ref5$encryption = _ref5.encryption, encryption = _ref5$encryption === void 0 ? "none" : _ref5$encryption, callback = _ref5.callback;
|
|
@@ -359,18 +359,18 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
359
359
|
ValidatePresence("fileInfo", fileInfo);
|
|
360
360
|
this.Log("Uploading files: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
361
361
|
if (!(encryption === "cgck")) {
|
|
362
|
-
_context7.next =
|
|
362
|
+
_context7.next = 9;
|
|
363
363
|
break;
|
|
364
364
|
}
|
|
365
|
-
_context7.next =
|
|
365
|
+
_context7.next = 8;
|
|
366
366
|
return this.EncryptionConk({
|
|
367
367
|
libraryId: libraryId,
|
|
368
368
|
objectId: objectId,
|
|
369
369
|
writeToken: writeToken
|
|
370
370
|
});
|
|
371
|
-
case
|
|
371
|
+
case 8:
|
|
372
372
|
conk = _context7.sent;
|
|
373
|
-
case
|
|
373
|
+
case 9:
|
|
374
374
|
// Extract file data into easily accessible hash while removing the data from the fileinfo for upload job creation
|
|
375
375
|
progress = {};
|
|
376
376
|
fileDataMap = {};
|
|
@@ -398,7 +398,7 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
398
398
|
if (callback) {
|
|
399
399
|
callback(progress);
|
|
400
400
|
}
|
|
401
|
-
_context7.next =
|
|
401
|
+
_context7.next = 18;
|
|
402
402
|
return this.CreateFileUploadJob({
|
|
403
403
|
libraryId: libraryId,
|
|
404
404
|
objectId: objectId,
|
|
@@ -406,7 +406,7 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
406
406
|
ops: fileInfo,
|
|
407
407
|
encryption: encryption
|
|
408
408
|
});
|
|
409
|
-
case
|
|
409
|
+
case 18:
|
|
410
410
|
_yield$this$CreateFil2 = _context7.sent;
|
|
411
411
|
id = _yield$this$CreateFil2.id;
|
|
412
412
|
jobs = _yield$this$CreateFil2.jobs;
|
|
@@ -419,33 +419,33 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
419
419
|
prepared = 0;
|
|
420
420
|
uploaded = 0; // Insert the data to upload into the job spec, encrypting if necessary
|
|
421
421
|
PrepareJobs = /*#__PURE__*/function () {
|
|
422
|
-
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
422
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
423
423
|
var j, jobId, job, f, _fileInfo, data;
|
|
424
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
424
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
425
425
|
while (1) switch (_context3.prev = _context3.next) {
|
|
426
426
|
case 0:
|
|
427
427
|
j = 0;
|
|
428
428
|
case 1:
|
|
429
429
|
if (!(j < jobs.length)) {
|
|
430
|
-
_context3.next =
|
|
430
|
+
_context3.next = 31;
|
|
431
431
|
break;
|
|
432
432
|
}
|
|
433
433
|
case 2:
|
|
434
434
|
if (!(prepared - uploaded > bufferSize)) {
|
|
435
|
-
_context3.next =
|
|
435
|
+
_context3.next = 7;
|
|
436
436
|
break;
|
|
437
437
|
}
|
|
438
|
-
_context3.next =
|
|
438
|
+
_context3.next = 5;
|
|
439
439
|
return new Promise(function (resolve) {
|
|
440
440
|
return setTimeout(resolve, 500);
|
|
441
441
|
});
|
|
442
|
-
case
|
|
442
|
+
case 5:
|
|
443
443
|
_context3.next = 2;
|
|
444
444
|
break;
|
|
445
|
-
case
|
|
445
|
+
case 7:
|
|
446
446
|
// Retrieve job info
|
|
447
447
|
jobId = jobs[j];
|
|
448
|
-
_context3.next =
|
|
448
|
+
_context3.next = 10;
|
|
449
449
|
return _this.UploadJobStatus({
|
|
450
450
|
libraryId: libraryId,
|
|
451
451
|
objectId: objectId,
|
|
@@ -453,12 +453,12 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
453
453
|
uploadId: id,
|
|
454
454
|
jobId: jobId
|
|
455
455
|
});
|
|
456
|
-
case
|
|
456
|
+
case 10:
|
|
457
457
|
job = _context3.sent;
|
|
458
458
|
f = 0;
|
|
459
|
-
case
|
|
459
|
+
case 12:
|
|
460
460
|
if (!(f < job.files.length)) {
|
|
461
|
-
_context3.next =
|
|
461
|
+
_context3.next = 25;
|
|
462
462
|
break;
|
|
463
463
|
}
|
|
464
464
|
_fileInfo = job.files[f];
|
|
@@ -472,33 +472,33 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
472
472
|
data = fileDataMap[_fileInfo.path].slice(_fileInfo.off, _fileInfo.off + _fileInfo.len);
|
|
473
473
|
}
|
|
474
474
|
if (!(encryption === "cgck")) {
|
|
475
|
-
_context3.next =
|
|
475
|
+
_context3.next = 20;
|
|
476
476
|
break;
|
|
477
477
|
}
|
|
478
|
-
_context3.next =
|
|
478
|
+
_context3.next = 19;
|
|
479
479
|
return _this.Crypto.Encrypt(conk, data);
|
|
480
|
-
case
|
|
480
|
+
case 19:
|
|
481
481
|
data = _context3.sent;
|
|
482
|
-
case
|
|
482
|
+
case 20:
|
|
483
483
|
job.files[f].data = data;
|
|
484
484
|
prepared += _fileInfo.len;
|
|
485
|
-
case
|
|
485
|
+
case 22:
|
|
486
486
|
f++;
|
|
487
|
-
_context3.next =
|
|
487
|
+
_context3.next = 12;
|
|
488
488
|
break;
|
|
489
|
-
case
|
|
489
|
+
case 25:
|
|
490
490
|
jobSpecs[j] = job;
|
|
491
491
|
|
|
492
492
|
// Wait for a bit to let upload start
|
|
493
|
-
_context3.next =
|
|
493
|
+
_context3.next = 28;
|
|
494
494
|
return new Promise(function (resolve) {
|
|
495
495
|
return setTimeout(resolve, 50);
|
|
496
496
|
});
|
|
497
|
-
case
|
|
497
|
+
case 28:
|
|
498
498
|
j++;
|
|
499
499
|
_context3.next = 1;
|
|
500
500
|
break;
|
|
501
|
-
case
|
|
501
|
+
case 31:
|
|
502
502
|
case "end":
|
|
503
503
|
return _context3.stop();
|
|
504
504
|
}
|
|
@@ -509,36 +509,36 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
509
509
|
};
|
|
510
510
|
}();
|
|
511
511
|
UploadJob = /*#__PURE__*/function () {
|
|
512
|
-
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobId, j) {
|
|
512
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobId, j) {
|
|
513
513
|
var jobSpec, files, _loop, f;
|
|
514
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
514
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context5) {
|
|
515
515
|
while (1) switch (_context5.prev = _context5.next) {
|
|
516
516
|
case 0:
|
|
517
517
|
if (jobSpecs[j]) {
|
|
518
|
-
_context5.next =
|
|
518
|
+
_context5.next = 5;
|
|
519
519
|
break;
|
|
520
520
|
}
|
|
521
|
-
_context5.next =
|
|
521
|
+
_context5.next = 3;
|
|
522
522
|
return new Promise(function (resolve) {
|
|
523
523
|
return setTimeout(resolve, 500);
|
|
524
524
|
});
|
|
525
|
-
case
|
|
525
|
+
case 3:
|
|
526
526
|
_context5.next = 0;
|
|
527
527
|
break;
|
|
528
|
-
case
|
|
528
|
+
case 5:
|
|
529
529
|
jobSpec = jobSpecs[j];
|
|
530
530
|
files = jobSpec.files; // Upload each item
|
|
531
531
|
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
532
|
-
var fileInfo, retries, succeeded
|
|
533
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
532
|
+
var fileInfo, retries, succeeded;
|
|
533
|
+
return _regeneratorRuntime.wrap(function _loop$(_context4) {
|
|
534
534
|
while (1) switch (_context4.prev = _context4.next) {
|
|
535
535
|
case 0:
|
|
536
536
|
fileInfo = files[f];
|
|
537
537
|
retries = 0;
|
|
538
538
|
succeeded = false;
|
|
539
|
-
case
|
|
540
|
-
_context4.prev =
|
|
541
|
-
_context4.next =
|
|
539
|
+
case 3:
|
|
540
|
+
_context4.prev = 3;
|
|
541
|
+
_context4.next = 6;
|
|
542
542
|
return _this.UploadFileData({
|
|
543
543
|
libraryId: libraryId,
|
|
544
544
|
objectId: objectId,
|
|
@@ -549,31 +549,31 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
549
549
|
fileData: fileInfo.data,
|
|
550
550
|
encryption: encryption
|
|
551
551
|
});
|
|
552
|
-
case
|
|
552
|
+
case 6:
|
|
553
553
|
succeeded = true;
|
|
554
|
-
_context4.next =
|
|
554
|
+
_context4.next = 17;
|
|
555
555
|
break;
|
|
556
|
-
case
|
|
557
|
-
_context4.prev =
|
|
558
|
-
|
|
559
|
-
_this.Log(
|
|
556
|
+
case 9:
|
|
557
|
+
_context4.prev = 9;
|
|
558
|
+
_context4.t0 = _context4["catch"](3);
|
|
559
|
+
_this.Log(_context4.t0, true);
|
|
560
560
|
retries += 1;
|
|
561
561
|
if (!(retries >= 10)) {
|
|
562
|
-
_context4.next =
|
|
562
|
+
_context4.next = 15;
|
|
563
563
|
break;
|
|
564
564
|
}
|
|
565
|
-
throw
|
|
566
|
-
case
|
|
567
|
-
_context4.next =
|
|
565
|
+
throw _context4.t0;
|
|
566
|
+
case 15:
|
|
567
|
+
_context4.next = 17;
|
|
568
568
|
return new Promise(function (resolve) {
|
|
569
569
|
return setTimeout(resolve, 10 * retries * 1000);
|
|
570
570
|
});
|
|
571
|
-
case
|
|
571
|
+
case 17:
|
|
572
572
|
if (!succeeded && retries < 10) {
|
|
573
|
-
_context4.next =
|
|
573
|
+
_context4.next = 3;
|
|
574
574
|
break;
|
|
575
575
|
}
|
|
576
|
-
case
|
|
576
|
+
case 18:
|
|
577
577
|
delete jobSpecs[j].files[f].data;
|
|
578
578
|
uploaded += fileInfo.len;
|
|
579
579
|
if (callback) {
|
|
@@ -582,24 +582,24 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
582
582
|
});
|
|
583
583
|
callback(progress);
|
|
584
584
|
}
|
|
585
|
-
case
|
|
585
|
+
case 21:
|
|
586
586
|
case "end":
|
|
587
587
|
return _context4.stop();
|
|
588
588
|
}
|
|
589
|
-
}, _loop, null, [[
|
|
589
|
+
}, _loop, null, [[3, 9]]);
|
|
590
590
|
});
|
|
591
591
|
f = 0;
|
|
592
|
-
case
|
|
592
|
+
case 9:
|
|
593
593
|
if (!(f < files.length)) {
|
|
594
|
-
_context5.next =
|
|
594
|
+
_context5.next = 14;
|
|
595
595
|
break;
|
|
596
596
|
}
|
|
597
|
-
return _context5.delegateYield(_loop(), "t0",
|
|
598
|
-
case
|
|
597
|
+
return _context5.delegateYield(_loop(), "t0", 11);
|
|
598
|
+
case 11:
|
|
599
599
|
f++;
|
|
600
|
-
_context5.next =
|
|
600
|
+
_context5.next = 9;
|
|
601
601
|
break;
|
|
602
|
-
case
|
|
602
|
+
case 14:
|
|
603
603
|
case "end":
|
|
604
604
|
return _context5.stop();
|
|
605
605
|
}
|
|
@@ -617,15 +617,15 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
617
617
|
rateTestJobs = Math.min(3, jobs.length);
|
|
618
618
|
rates = [];
|
|
619
619
|
j = 0;
|
|
620
|
-
case
|
|
620
|
+
case 33:
|
|
621
621
|
if (!(j < rateTestJobs)) {
|
|
622
|
-
_context7.next =
|
|
622
|
+
_context7.next = 43;
|
|
623
623
|
break;
|
|
624
624
|
}
|
|
625
625
|
start = new Date().getTime();
|
|
626
|
-
_context7.next =
|
|
626
|
+
_context7.next = 37;
|
|
627
627
|
return UploadJob(jobs[j], j);
|
|
628
|
-
case
|
|
628
|
+
case 37:
|
|
629
629
|
elapsed = (new Date().getTime() - start) / 1000;
|
|
630
630
|
size = jobSpecs[j].files.map(function (file) {
|
|
631
631
|
return file.len;
|
|
@@ -633,30 +633,30 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
633
633
|
return length + total;
|
|
634
634
|
}, 0);
|
|
635
635
|
rates.push(size / elapsed / (1024 * 1024));
|
|
636
|
-
case
|
|
636
|
+
case 40:
|
|
637
637
|
j++;
|
|
638
|
-
_context7.next =
|
|
638
|
+
_context7.next = 33;
|
|
639
639
|
break;
|
|
640
|
-
case
|
|
640
|
+
case 43:
|
|
641
641
|
averageRate = rates.reduce(function (mbps, total) {
|
|
642
642
|
return mbps + total;
|
|
643
643
|
}, 0) / rateTestJobs; // Upload remaining jobs in parallel
|
|
644
644
|
concurrentUploads = Math.min(5, Math.ceil(averageRate / 2));
|
|
645
|
-
_context7.next =
|
|
645
|
+
_context7.next = 47;
|
|
646
646
|
return this.utils.LimitedMap(concurrentUploads, jobs, /*#__PURE__*/function () {
|
|
647
|
-
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(jobId, j) {
|
|
648
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
647
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(jobId, j) {
|
|
648
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
|
|
649
649
|
while (1) switch (_context6.prev = _context6.next) {
|
|
650
650
|
case 0:
|
|
651
651
|
if (!(j < rateTestJobs)) {
|
|
652
|
-
_context6.next =
|
|
652
|
+
_context6.next = 2;
|
|
653
653
|
break;
|
|
654
654
|
}
|
|
655
655
|
return _context6.abrupt("return");
|
|
656
|
-
case 1:
|
|
657
|
-
_context6.next = 2;
|
|
658
|
-
return UploadJob(jobId, j);
|
|
659
656
|
case 2:
|
|
657
|
+
_context6.next = 4;
|
|
658
|
+
return UploadJob(jobId, j);
|
|
659
|
+
case 4:
|
|
660
660
|
case "end":
|
|
661
661
|
return _context6.stop();
|
|
662
662
|
}
|
|
@@ -666,7 +666,7 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
666
666
|
return _ref9.apply(this, arguments);
|
|
667
667
|
};
|
|
668
668
|
}());
|
|
669
|
-
case
|
|
669
|
+
case 47:
|
|
670
670
|
case "end":
|
|
671
671
|
return _context7.stop();
|
|
672
672
|
}
|
|
@@ -677,12 +677,12 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
677
677
|
};
|
|
678
678
|
}();
|
|
679
679
|
exports.CreateFileUploadJob = /*#__PURE__*/function () {
|
|
680
|
-
var
|
|
681
|
-
var libraryId, objectId, writeToken, ops,
|
|
682
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
680
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
|
|
681
|
+
var libraryId, objectId, writeToken, ops, _ref10$defaults, defaults, _ref10$encryption, encryption, body, path;
|
|
682
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context8) {
|
|
683
683
|
while (1) switch (_context8.prev = _context8.next) {
|
|
684
684
|
case 0:
|
|
685
|
-
libraryId =
|
|
685
|
+
libraryId = _ref10.libraryId, objectId = _ref10.objectId, writeToken = _ref10.writeToken, ops = _ref10.ops, _ref10$defaults = _ref10.defaults, defaults = _ref10$defaults === void 0 ? {} : _ref10$defaults, _ref10$encryption = _ref10.encryption, encryption = _ref10$encryption === void 0 ? "none" : _ref10$encryption;
|
|
686
686
|
ValidateParameters({
|
|
687
687
|
libraryId: libraryId,
|
|
688
688
|
objectId: objectId
|
|
@@ -702,178 +702,178 @@ exports.CreateFileUploadJob = /*#__PURE__*/function () {
|
|
|
702
702
|
ops: ops
|
|
703
703
|
};
|
|
704
704
|
path = UrlJoin("q", writeToken, "file_jobs");
|
|
705
|
-
|
|
706
|
-
_context8.next =
|
|
705
|
+
_context8.t0 = this.HttpClient;
|
|
706
|
+
_context8.next = 11;
|
|
707
707
|
return this.authClient.AuthorizationHeader({
|
|
708
708
|
libraryId: libraryId,
|
|
709
709
|
objectId: objectId,
|
|
710
710
|
update: true,
|
|
711
711
|
encryption: encryption
|
|
712
712
|
});
|
|
713
|
-
case
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
headers:
|
|
713
|
+
case 11:
|
|
714
|
+
_context8.t1 = _context8.sent;
|
|
715
|
+
_context8.t2 = path;
|
|
716
|
+
_context8.t3 = body;
|
|
717
|
+
_context8.t4 = {
|
|
718
|
+
headers: _context8.t1,
|
|
719
719
|
method: "POST",
|
|
720
|
-
path:
|
|
721
|
-
body:
|
|
720
|
+
path: _context8.t2,
|
|
721
|
+
body: _context8.t3,
|
|
722
722
|
allowFailover: false
|
|
723
723
|
};
|
|
724
|
-
return _context8.abrupt("return",
|
|
725
|
-
case
|
|
724
|
+
return _context8.abrupt("return", _context8.t0.RequestJsonBody.call(_context8.t0, _context8.t4));
|
|
725
|
+
case 16:
|
|
726
726
|
case "end":
|
|
727
727
|
return _context8.stop();
|
|
728
728
|
}
|
|
729
729
|
}, _callee7, this);
|
|
730
730
|
}));
|
|
731
731
|
return function (_x8) {
|
|
732
|
-
return
|
|
732
|
+
return _ref11.apply(this, arguments);
|
|
733
733
|
};
|
|
734
734
|
}();
|
|
735
735
|
exports.UploadStatus = /*#__PURE__*/function () {
|
|
736
|
-
var
|
|
737
|
-
var libraryId, objectId, writeToken, uploadId, path
|
|
738
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
736
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
737
|
+
var libraryId, objectId, writeToken, uploadId, path;
|
|
738
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
739
739
|
while (1) switch (_context9.prev = _context9.next) {
|
|
740
740
|
case 0:
|
|
741
|
-
libraryId =
|
|
741
|
+
libraryId = _ref12.libraryId, objectId = _ref12.objectId, writeToken = _ref12.writeToken, uploadId = _ref12.uploadId;
|
|
742
742
|
ValidateParameters({
|
|
743
743
|
libraryId: libraryId,
|
|
744
744
|
objectId: objectId
|
|
745
745
|
});
|
|
746
746
|
ValidateWriteToken(writeToken);
|
|
747
747
|
path = UrlJoin("q", writeToken, "file_jobs", uploadId);
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
_context9.next =
|
|
748
|
+
_context9.t0 = this.utils;
|
|
749
|
+
_context9.t1 = this.HttpClient;
|
|
750
|
+
_context9.next = 8;
|
|
751
751
|
return this.authClient.AuthorizationHeader({
|
|
752
752
|
libraryId: libraryId,
|
|
753
753
|
objectId: objectId,
|
|
754
754
|
update: true
|
|
755
755
|
});
|
|
756
|
-
case
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
headers:
|
|
756
|
+
case 8:
|
|
757
|
+
_context9.t2 = _context9.sent;
|
|
758
|
+
_context9.t3 = path;
|
|
759
|
+
_context9.t4 = {
|
|
760
|
+
headers: _context9.t2,
|
|
761
761
|
method: "GET",
|
|
762
|
-
path:
|
|
762
|
+
path: _context9.t3,
|
|
763
763
|
allowFailover: false
|
|
764
764
|
};
|
|
765
|
-
|
|
766
|
-
return _context9.abrupt("return",
|
|
767
|
-
case
|
|
765
|
+
_context9.t5 = _context9.t1.Request.call(_context9.t1, _context9.t4);
|
|
766
|
+
return _context9.abrupt("return", _context9.t0.ResponseToJson.call(_context9.t0, _context9.t5));
|
|
767
|
+
case 13:
|
|
768
768
|
case "end":
|
|
769
769
|
return _context9.stop();
|
|
770
770
|
}
|
|
771
771
|
}, _callee8, this);
|
|
772
772
|
}));
|
|
773
773
|
return function (_x9) {
|
|
774
|
-
return
|
|
774
|
+
return _ref13.apply(this, arguments);
|
|
775
775
|
};
|
|
776
776
|
}();
|
|
777
777
|
exports.UploadJobStatus = /*#__PURE__*/function () {
|
|
778
|
-
var
|
|
779
|
-
var libraryId, objectId, writeToken, uploadId, jobId, path, response, newResponse
|
|
780
|
-
return _regeneratorRuntime.wrap(function (
|
|
781
|
-
while (1) switch (
|
|
778
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref14) {
|
|
779
|
+
var libraryId, objectId, writeToken, uploadId, jobId, path, response, newResponse;
|
|
780
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context10) {
|
|
781
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
782
782
|
case 0:
|
|
783
|
-
libraryId =
|
|
783
|
+
libraryId = _ref14.libraryId, objectId = _ref14.objectId, writeToken = _ref14.writeToken, uploadId = _ref14.uploadId, jobId = _ref14.jobId;
|
|
784
784
|
ValidateParameters({
|
|
785
785
|
libraryId: libraryId,
|
|
786
786
|
objectId: objectId
|
|
787
787
|
});
|
|
788
788
|
ValidateWriteToken(writeToken);
|
|
789
789
|
path = UrlJoin("q", writeToken, "file_jobs", uploadId, "uploads", jobId);
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
790
|
+
_context10.t0 = this.utils;
|
|
791
|
+
_context10.t1 = this.HttpClient;
|
|
792
|
+
_context10.next = 8;
|
|
793
793
|
return this.authClient.AuthorizationHeader({
|
|
794
794
|
libraryId: libraryId,
|
|
795
795
|
objectId: objectId,
|
|
796
796
|
update: true
|
|
797
797
|
});
|
|
798
|
-
case
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
798
|
+
case 8:
|
|
799
|
+
_context10.t2 = _context10.sent;
|
|
800
|
+
_context10.t3 = path;
|
|
801
|
+
_context10.t4 = {
|
|
802
802
|
start: 0,
|
|
803
803
|
limit: 10000
|
|
804
804
|
};
|
|
805
|
-
|
|
806
|
-
headers:
|
|
805
|
+
_context10.t5 = {
|
|
806
|
+
headers: _context10.t2,
|
|
807
807
|
method: "GET",
|
|
808
|
-
path:
|
|
808
|
+
path: _context10.t3,
|
|
809
809
|
allowFailover: false,
|
|
810
|
-
queryParams:
|
|
810
|
+
queryParams: _context10.t4
|
|
811
811
|
};
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
return
|
|
815
|
-
case
|
|
816
|
-
response =
|
|
817
|
-
case
|
|
812
|
+
_context10.t6 = _context10.t1.Request.call(_context10.t1, _context10.t5);
|
|
813
|
+
_context10.next = 15;
|
|
814
|
+
return _context10.t0.ResponseToJson.call(_context10.t0, _context10.t6);
|
|
815
|
+
case 15:
|
|
816
|
+
response = _context10.sent;
|
|
817
|
+
case 16:
|
|
818
818
|
if (!(response.next !== response.total && response.next >= 0)) {
|
|
819
|
-
|
|
819
|
+
_context10.next = 33;
|
|
820
820
|
break;
|
|
821
821
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
822
|
+
_context10.t7 = this.utils;
|
|
823
|
+
_context10.t8 = this.HttpClient;
|
|
824
|
+
_context10.next = 21;
|
|
825
825
|
return this.authClient.AuthorizationHeader({
|
|
826
826
|
libraryId: libraryId,
|
|
827
827
|
objectId: objectId,
|
|
828
828
|
update: true
|
|
829
829
|
});
|
|
830
|
-
case
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
830
|
+
case 21:
|
|
831
|
+
_context10.t9 = _context10.sent;
|
|
832
|
+
_context10.t10 = path;
|
|
833
|
+
_context10.t11 = {
|
|
834
834
|
start: response.next
|
|
835
835
|
};
|
|
836
|
-
|
|
837
|
-
headers:
|
|
836
|
+
_context10.t12 = {
|
|
837
|
+
headers: _context10.t9,
|
|
838
838
|
method: "GET",
|
|
839
|
-
path:
|
|
839
|
+
path: _context10.t10,
|
|
840
840
|
allowFailover: false,
|
|
841
|
-
queryParams:
|
|
841
|
+
queryParams: _context10.t11
|
|
842
842
|
};
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
return
|
|
846
|
-
case
|
|
847
|
-
newResponse =
|
|
843
|
+
_context10.t13 = _context10.t8.Request.call(_context10.t8, _context10.t12);
|
|
844
|
+
_context10.next = 28;
|
|
845
|
+
return _context10.t7.ResponseToJson.call(_context10.t7, _context10.t13);
|
|
846
|
+
case 28:
|
|
847
|
+
newResponse = _context10.sent;
|
|
848
848
|
response.files = [].concat(_toConsumableArray(response.files), _toConsumableArray(newResponse.files));
|
|
849
849
|
response.next = newResponse.next;
|
|
850
|
-
|
|
850
|
+
_context10.next = 16;
|
|
851
851
|
break;
|
|
852
|
-
case
|
|
853
|
-
return
|
|
854
|
-
case
|
|
852
|
+
case 33:
|
|
853
|
+
return _context10.abrupt("return", response);
|
|
854
|
+
case 34:
|
|
855
855
|
case "end":
|
|
856
|
-
return
|
|
856
|
+
return _context10.stop();
|
|
857
857
|
}
|
|
858
858
|
}, _callee9, this);
|
|
859
859
|
}));
|
|
860
|
-
return function (
|
|
861
|
-
return
|
|
860
|
+
return function (_x10) {
|
|
861
|
+
return _ref15.apply(this, arguments);
|
|
862
862
|
};
|
|
863
863
|
}();
|
|
864
864
|
exports.UploadFileData = /*#__PURE__*/function () {
|
|
865
|
-
var
|
|
866
|
-
var libraryId, objectId, writeToken, encryption, uploadId, jobId, filePath, fileData, jobStatus, fileStatus, path
|
|
867
|
-
return _regeneratorRuntime.wrap(function (
|
|
868
|
-
while (1) switch (
|
|
865
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref16) {
|
|
866
|
+
var libraryId, objectId, writeToken, encryption, uploadId, jobId, filePath, fileData, jobStatus, fileStatus, path;
|
|
867
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context11) {
|
|
868
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
869
869
|
case 0:
|
|
870
|
-
libraryId =
|
|
870
|
+
libraryId = _ref16.libraryId, objectId = _ref16.objectId, writeToken = _ref16.writeToken, encryption = _ref16.encryption, uploadId = _ref16.uploadId, jobId = _ref16.jobId, filePath = _ref16.filePath, fileData = _ref16.fileData;
|
|
871
871
|
ValidateParameters({
|
|
872
872
|
libraryId: libraryId,
|
|
873
873
|
objectId: objectId
|
|
874
874
|
});
|
|
875
875
|
ValidateWriteToken(writeToken);
|
|
876
|
-
|
|
876
|
+
_context11.next = 5;
|
|
877
877
|
return this.UploadJobStatus({
|
|
878
878
|
libraryId: libraryId,
|
|
879
879
|
objectId: objectId,
|
|
@@ -881,8 +881,8 @@ exports.UploadFileData = /*#__PURE__*/function () {
|
|
|
881
881
|
uploadId: uploadId,
|
|
882
882
|
jobId: jobId
|
|
883
883
|
});
|
|
884
|
-
case
|
|
885
|
-
jobStatus =
|
|
884
|
+
case 5:
|
|
885
|
+
jobStatus = _context11.sent;
|
|
886
886
|
// Find the status of this file
|
|
887
887
|
fileStatus = jobStatus.files.find(function (item) {
|
|
888
888
|
return item.path === filePath;
|
|
@@ -891,64 +891,64 @@ exports.UploadFileData = /*#__PURE__*/function () {
|
|
|
891
891
|
fileStatus = fileStatus.encrypted;
|
|
892
892
|
}
|
|
893
893
|
if (!(fileStatus.rem === 0)) {
|
|
894
|
-
|
|
894
|
+
_context11.next = 12;
|
|
895
895
|
break;
|
|
896
896
|
}
|
|
897
|
-
return
|
|
898
|
-
case
|
|
897
|
+
return _context11.abrupt("return");
|
|
898
|
+
case 12:
|
|
899
899
|
if (fileStatus.skip) {
|
|
900
900
|
fileData = fileData.slice(fileStatus.skip);
|
|
901
901
|
}
|
|
902
|
-
case
|
|
902
|
+
case 13:
|
|
903
903
|
path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
904
|
+
_context11.t0 = this.utils;
|
|
905
|
+
_context11.t1 = this.HttpClient;
|
|
906
|
+
_context11.t2 = path;
|
|
907
|
+
_context11.t3 = fileData;
|
|
908
|
+
_context11.t4 = _objectSpread;
|
|
909
|
+
_context11.t5 = {
|
|
910
910
|
"Content-type": "application/octet-stream"
|
|
911
911
|
};
|
|
912
|
-
|
|
912
|
+
_context11.next = 22;
|
|
913
913
|
return this.authClient.AuthorizationHeader({
|
|
914
914
|
libraryId: libraryId,
|
|
915
915
|
objectId: objectId,
|
|
916
916
|
update: true
|
|
917
917
|
});
|
|
918
|
-
case
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
918
|
+
case 22:
|
|
919
|
+
_context11.t6 = _context11.sent;
|
|
920
|
+
_context11.t7 = (0, _context11.t4)(_context11.t5, _context11.t6);
|
|
921
|
+
_context11.t8 = {
|
|
922
922
|
method: "POST",
|
|
923
|
-
path:
|
|
924
|
-
body:
|
|
923
|
+
path: _context11.t2,
|
|
924
|
+
body: _context11.t3,
|
|
925
925
|
bodyType: "BINARY",
|
|
926
|
-
headers:
|
|
926
|
+
headers: _context11.t7,
|
|
927
927
|
allowFailover: false,
|
|
928
928
|
allowRetry: false
|
|
929
929
|
};
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
return
|
|
933
|
-
case
|
|
934
|
-
return
|
|
935
|
-
case
|
|
930
|
+
_context11.t9 = _context11.t1.Request.call(_context11.t1, _context11.t8);
|
|
931
|
+
_context11.next = 28;
|
|
932
|
+
return _context11.t0.ResponseToJson.call(_context11.t0, _context11.t9);
|
|
933
|
+
case 28:
|
|
934
|
+
return _context11.abrupt("return", _context11.sent);
|
|
935
|
+
case 29:
|
|
936
936
|
case "end":
|
|
937
|
-
return
|
|
937
|
+
return _context11.stop();
|
|
938
938
|
}
|
|
939
|
-
},
|
|
939
|
+
}, _callee10, this);
|
|
940
940
|
}));
|
|
941
|
-
return function (
|
|
942
|
-
return
|
|
941
|
+
return function (_x11) {
|
|
942
|
+
return _ref17.apply(this, arguments);
|
|
943
943
|
};
|
|
944
944
|
}();
|
|
945
945
|
exports.FinalizeUploadJob = /*#__PURE__*/function () {
|
|
946
|
-
var
|
|
947
|
-
var libraryId, objectId, writeToken, path
|
|
948
|
-
return _regeneratorRuntime.wrap(function (
|
|
949
|
-
while (1) switch (
|
|
946
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref18) {
|
|
947
|
+
var libraryId, objectId, writeToken, path;
|
|
948
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context12) {
|
|
949
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
950
950
|
case 0:
|
|
951
|
-
libraryId =
|
|
951
|
+
libraryId = _ref18.libraryId, objectId = _ref18.objectId, writeToken = _ref18.writeToken;
|
|
952
952
|
ValidateParameters({
|
|
953
953
|
libraryId: libraryId,
|
|
954
954
|
objectId: objectId
|
|
@@ -956,33 +956,33 @@ exports.FinalizeUploadJob = /*#__PURE__*/function () {
|
|
|
956
956
|
ValidateWriteToken(writeToken);
|
|
957
957
|
this.Log("Finalizing upload job: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
958
958
|
path = UrlJoin("q", writeToken, "files");
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
959
|
+
_context12.t0 = this.HttpClient;
|
|
960
|
+
_context12.t1 = path;
|
|
961
|
+
_context12.next = 9;
|
|
962
962
|
return this.authClient.AuthorizationHeader({
|
|
963
963
|
libraryId: libraryId,
|
|
964
964
|
objectId: objectId,
|
|
965
965
|
update: true
|
|
966
966
|
});
|
|
967
|
-
case
|
|
968
|
-
|
|
969
|
-
|
|
967
|
+
case 9:
|
|
968
|
+
_context12.t2 = _context12.sent;
|
|
969
|
+
_context12.t3 = {
|
|
970
970
|
method: "POST",
|
|
971
|
-
path:
|
|
971
|
+
path: _context12.t1,
|
|
972
972
|
bodyType: "BINARY",
|
|
973
|
-
headers:
|
|
973
|
+
headers: _context12.t2,
|
|
974
974
|
allowFailover: false
|
|
975
975
|
};
|
|
976
|
-
|
|
977
|
-
return
|
|
978
|
-
case
|
|
976
|
+
_context12.next = 13;
|
|
977
|
+
return _context12.t0.Request.call(_context12.t0, _context12.t3);
|
|
978
|
+
case 13:
|
|
979
979
|
case "end":
|
|
980
|
-
return
|
|
980
|
+
return _context12.stop();
|
|
981
981
|
}
|
|
982
|
-
},
|
|
982
|
+
}, _callee11, this);
|
|
983
983
|
}));
|
|
984
|
-
return function (
|
|
985
|
-
return
|
|
984
|
+
return function (_x12) {
|
|
985
|
+
return _ref19.apply(this, arguments);
|
|
986
986
|
};
|
|
987
987
|
}();
|
|
988
988
|
|
|
@@ -998,12 +998,12 @@ exports.FinalizeUploadJob = /*#__PURE__*/function () {
|
|
|
998
998
|
* @param {Array<string>} filePaths - List of file paths to create
|
|
999
999
|
*/
|
|
1000
1000
|
exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
1001
|
-
var
|
|
1001
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref20) {
|
|
1002
1002
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1003
|
-
return _regeneratorRuntime.wrap(function (
|
|
1004
|
-
while (1) switch (
|
|
1003
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context13) {
|
|
1004
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1005
1005
|
case 0:
|
|
1006
|
-
libraryId =
|
|
1006
|
+
libraryId = _ref20.libraryId, objectId = _ref20.objectId, writeToken = _ref20.writeToken, filePaths = _ref20.filePaths;
|
|
1007
1007
|
ValidateParameters({
|
|
1008
1008
|
libraryId: libraryId,
|
|
1009
1009
|
objectId: objectId
|
|
@@ -1018,21 +1018,21 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
|
1018
1018
|
path: path
|
|
1019
1019
|
};
|
|
1020
1020
|
});
|
|
1021
|
-
|
|
1021
|
+
_context13.next = 8;
|
|
1022
1022
|
return this.CreateFileUploadJob({
|
|
1023
1023
|
libraryId: libraryId,
|
|
1024
1024
|
objectId: objectId,
|
|
1025
1025
|
writeToken: writeToken,
|
|
1026
1026
|
ops: ops
|
|
1027
1027
|
});
|
|
1028
|
-
case
|
|
1028
|
+
case 8:
|
|
1029
1029
|
case "end":
|
|
1030
|
-
return
|
|
1030
|
+
return _context13.stop();
|
|
1031
1031
|
}
|
|
1032
|
-
},
|
|
1032
|
+
}, _callee12, this);
|
|
1033
1033
|
}));
|
|
1034
|
-
return function (
|
|
1035
|
-
return
|
|
1034
|
+
return function (_x13) {
|
|
1035
|
+
return _ref21.apply(this, arguments);
|
|
1036
1036
|
};
|
|
1037
1037
|
}();
|
|
1038
1038
|
|
|
@@ -1048,12 +1048,12 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
|
1048
1048
|
* @param {Array<string>} filePaths - List of file paths to move. Format: ```[ { "path": "original/path", to: "new/path" } ]```
|
|
1049
1049
|
*/
|
|
1050
1050
|
exports.MoveFiles = /*#__PURE__*/function () {
|
|
1051
|
-
var
|
|
1051
|
+
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref22) {
|
|
1052
1052
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1053
|
-
return _regeneratorRuntime.wrap(function (
|
|
1054
|
-
while (1) switch (
|
|
1053
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context14) {
|
|
1054
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1055
1055
|
case 0:
|
|
1056
|
-
libraryId =
|
|
1056
|
+
libraryId = _ref22.libraryId, objectId = _ref22.objectId, writeToken = _ref22.writeToken, filePaths = _ref22.filePaths;
|
|
1057
1057
|
ValidateParameters({
|
|
1058
1058
|
libraryId: libraryId,
|
|
1059
1059
|
objectId: objectId
|
|
@@ -1061,30 +1061,30 @@ exports.MoveFiles = /*#__PURE__*/function () {
|
|
|
1061
1061
|
ValidateWriteToken(writeToken);
|
|
1062
1062
|
this.Log("Moving Files: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
1063
1063
|
this.Log(filePaths);
|
|
1064
|
-
ops = filePaths.map(function (
|
|
1065
|
-
var path =
|
|
1066
|
-
to =
|
|
1064
|
+
ops = filePaths.map(function (_ref24) {
|
|
1065
|
+
var path = _ref24.path,
|
|
1066
|
+
to = _ref24.to;
|
|
1067
1067
|
return {
|
|
1068
1068
|
op: "move",
|
|
1069
1069
|
copy_move_source_path: path,
|
|
1070
1070
|
path: to
|
|
1071
1071
|
};
|
|
1072
1072
|
});
|
|
1073
|
-
|
|
1073
|
+
_context14.next = 8;
|
|
1074
1074
|
return this.CreateFileUploadJob({
|
|
1075
1075
|
libraryId: libraryId,
|
|
1076
1076
|
objectId: objectId,
|
|
1077
1077
|
writeToken: writeToken,
|
|
1078
1078
|
ops: ops
|
|
1079
1079
|
});
|
|
1080
|
-
case
|
|
1080
|
+
case 8:
|
|
1081
1081
|
case "end":
|
|
1082
|
-
return
|
|
1082
|
+
return _context14.stop();
|
|
1083
1083
|
}
|
|
1084
|
-
},
|
|
1084
|
+
}, _callee13, this);
|
|
1085
1085
|
}));
|
|
1086
|
-
return function (
|
|
1087
|
-
return
|
|
1086
|
+
return function (_x14) {
|
|
1087
|
+
return _ref23.apply(this, arguments);
|
|
1088
1088
|
};
|
|
1089
1089
|
}();
|
|
1090
1090
|
|
|
@@ -1100,12 +1100,12 @@ exports.MoveFiles = /*#__PURE__*/function () {
|
|
|
1100
1100
|
* @param {Array<string>} filePaths - List of file paths to delete
|
|
1101
1101
|
*/
|
|
1102
1102
|
exports.DeleteFiles = /*#__PURE__*/function () {
|
|
1103
|
-
var
|
|
1103
|
+
var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref25) {
|
|
1104
1104
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1105
|
-
return _regeneratorRuntime.wrap(function (
|
|
1106
|
-
while (1) switch (
|
|
1105
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context15) {
|
|
1106
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1107
1107
|
case 0:
|
|
1108
|
-
libraryId =
|
|
1108
|
+
libraryId = _ref25.libraryId, objectId = _ref25.objectId, writeToken = _ref25.writeToken, filePaths = _ref25.filePaths;
|
|
1109
1109
|
ValidateParameters({
|
|
1110
1110
|
libraryId: libraryId,
|
|
1111
1111
|
objectId: objectId
|
|
@@ -1119,21 +1119,21 @@ exports.DeleteFiles = /*#__PURE__*/function () {
|
|
|
1119
1119
|
path: path
|
|
1120
1120
|
};
|
|
1121
1121
|
});
|
|
1122
|
-
|
|
1122
|
+
_context15.next = 8;
|
|
1123
1123
|
return this.CreateFileUploadJob({
|
|
1124
1124
|
libraryId: libraryId,
|
|
1125
1125
|
objectId: objectId,
|
|
1126
1126
|
writeToken: writeToken,
|
|
1127
1127
|
ops: ops
|
|
1128
1128
|
});
|
|
1129
|
-
case
|
|
1129
|
+
case 8:
|
|
1130
1130
|
case "end":
|
|
1131
|
-
return
|
|
1131
|
+
return _context15.stop();
|
|
1132
1132
|
}
|
|
1133
|
-
},
|
|
1133
|
+
}, _callee14, this);
|
|
1134
1134
|
}));
|
|
1135
|
-
return function (
|
|
1136
|
-
return
|
|
1135
|
+
return function (_x15) {
|
|
1136
|
+
return _ref26.apply(this, arguments);
|
|
1137
1137
|
};
|
|
1138
1138
|
}();
|
|
1139
1139
|
|
|
@@ -1162,18 +1162,18 @@ exports.DeleteFiles = /*#__PURE__*/function () {
|
|
|
1162
1162
|
* @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, file data in the requested format otherwise
|
|
1163
1163
|
*/
|
|
1164
1164
|
exports.DownloadFile = /*#__PURE__*/function () {
|
|
1165
|
-
var
|
|
1165
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref27) {
|
|
1166
1166
|
var libraryId,
|
|
1167
1167
|
objectId,
|
|
1168
1168
|
versionHash,
|
|
1169
1169
|
writeToken,
|
|
1170
1170
|
filePath,
|
|
1171
|
-
|
|
1171
|
+
_ref27$format,
|
|
1172
1172
|
format,
|
|
1173
|
-
|
|
1173
|
+
_ref27$chunked,
|
|
1174
1174
|
chunked,
|
|
1175
1175
|
chunkSize,
|
|
1176
|
-
|
|
1176
|
+
_ref27$clientSideDecr,
|
|
1177
1177
|
clientSideDecryption,
|
|
1178
1178
|
callback,
|
|
1179
1179
|
fileInfo,
|
|
@@ -1184,27 +1184,11 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1184
1184
|
ownerCapKey,
|
|
1185
1185
|
ownerCap,
|
|
1186
1186
|
bytesTotal,
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
_t45,
|
|
1191
|
-
_t46,
|
|
1192
|
-
_t47,
|
|
1193
|
-
_t48,
|
|
1194
|
-
_t49,
|
|
1195
|
-
_t50,
|
|
1196
|
-
_t51,
|
|
1197
|
-
_t52,
|
|
1198
|
-
_t53,
|
|
1199
|
-
_t54,
|
|
1200
|
-
_t55,
|
|
1201
|
-
_t56,
|
|
1202
|
-
_t57,
|
|
1203
|
-
_t58;
|
|
1204
|
-
return _regeneratorRuntime.wrap(function (_context14) {
|
|
1205
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
1187
|
+
_args16 = arguments;
|
|
1188
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context16) {
|
|
1189
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1206
1190
|
case 0:
|
|
1207
|
-
libraryId =
|
|
1191
|
+
libraryId = _ref27.libraryId, objectId = _ref27.objectId, versionHash = _ref27.versionHash, writeToken = _ref27.writeToken, filePath = _ref27.filePath, _ref27$format = _ref27.format, format = _ref27$format === void 0 ? "arrayBuffer" : _ref27$format, _ref27$chunked = _ref27.chunked, chunked = _ref27$chunked === void 0 ? false : _ref27$chunked, chunkSize = _ref27.chunkSize, _ref27$clientSideDecr = _ref27.clientSideDecryption, clientSideDecryption = _ref27$clientSideDecr === void 0 ? false : _ref27$clientSideDecr, callback = _ref27.callback;
|
|
1208
1192
|
ValidateParameters({
|
|
1209
1193
|
libraryId: libraryId,
|
|
1210
1194
|
objectId: objectId,
|
|
@@ -1214,7 +1198,7 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1214
1198
|
if (versionHash) {
|
|
1215
1199
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1216
1200
|
}
|
|
1217
|
-
|
|
1201
|
+
_context16.next = 6;
|
|
1218
1202
|
return this.ContentObjectMetadata({
|
|
1219
1203
|
libraryId: libraryId,
|
|
1220
1204
|
objectId: objectId,
|
|
@@ -1222,12 +1206,12 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1222
1206
|
writeToken: writeToken,
|
|
1223
1207
|
metadataSubtree: UrlJoin("files", filePath)
|
|
1224
1208
|
});
|
|
1225
|
-
case
|
|
1226
|
-
fileInfo =
|
|
1209
|
+
case 6:
|
|
1210
|
+
fileInfo = _context16.sent;
|
|
1227
1211
|
encrypted = fileInfo && fileInfo["."].encryption && fileInfo["."].encryption.scheme === "cgck";
|
|
1228
1212
|
encryption = encrypted ? "cgck" : undefined;
|
|
1229
1213
|
path = encrypted && !clientSideDecryption ? UrlJoin("q", writeToken || versionHash || objectId, "rep", "files_download", filePath) : UrlJoin("q", writeToken || versionHash || objectId, "files", filePath);
|
|
1230
|
-
|
|
1214
|
+
_context16.next = 12;
|
|
1231
1215
|
return this.authClient.AuthorizationHeader({
|
|
1232
1216
|
libraryId: libraryId,
|
|
1233
1217
|
objectId: objectId,
|
|
@@ -1235,49 +1219,49 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1235
1219
|
encryption: encryption,
|
|
1236
1220
|
makeAccessRequest: encryption === "cgck"
|
|
1237
1221
|
});
|
|
1238
|
-
case
|
|
1239
|
-
headers =
|
|
1222
|
+
case 12:
|
|
1223
|
+
headers = _context16.sent;
|
|
1240
1224
|
headers.Accept = "*/*";
|
|
1241
1225
|
|
|
1242
1226
|
// If not owner, indicate re-encryption
|
|
1243
1227
|
ownerCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
|
|
1244
|
-
|
|
1228
|
+
_context16.next = 17;
|
|
1245
1229
|
return this.ContentObjectMetadata({
|
|
1246
1230
|
libraryId: libraryId,
|
|
1247
1231
|
objectId: objectId,
|
|
1248
1232
|
versionHash: versionHash,
|
|
1249
1233
|
metadataSubtree: ownerCapKey
|
|
1250
1234
|
});
|
|
1251
|
-
case
|
|
1252
|
-
ownerCap =
|
|
1253
|
-
|
|
1254
|
-
if (!
|
|
1255
|
-
|
|
1235
|
+
case 17:
|
|
1236
|
+
ownerCap = _context16.sent;
|
|
1237
|
+
_context16.t1 = encrypted;
|
|
1238
|
+
if (!_context16.t1) {
|
|
1239
|
+
_context16.next = 26;
|
|
1256
1240
|
break;
|
|
1257
1241
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1242
|
+
_context16.t2 = this.utils;
|
|
1243
|
+
_context16.t3 = this.signer.address;
|
|
1244
|
+
_context16.next = 24;
|
|
1261
1245
|
return this.ContentObjectOwner({
|
|
1262
1246
|
objectId: objectId
|
|
1263
1247
|
});
|
|
1264
|
-
case
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
case
|
|
1268
|
-
|
|
1269
|
-
if (!
|
|
1270
|
-
|
|
1248
|
+
case 24:
|
|
1249
|
+
_context16.t4 = _context16.sent;
|
|
1250
|
+
_context16.t1 = !_context16.t2.EqualAddress.call(_context16.t2, _context16.t3, _context16.t4);
|
|
1251
|
+
case 26:
|
|
1252
|
+
_context16.t0 = _context16.t1;
|
|
1253
|
+
if (!_context16.t0) {
|
|
1254
|
+
_context16.next = 29;
|
|
1271
1255
|
break;
|
|
1272
1256
|
}
|
|
1273
|
-
|
|
1274
|
-
case
|
|
1275
|
-
if (!
|
|
1276
|
-
|
|
1257
|
+
_context16.t0 = !ownerCap;
|
|
1258
|
+
case 29:
|
|
1259
|
+
if (!_context16.t0) {
|
|
1260
|
+
_context16.next = 31;
|
|
1277
1261
|
break;
|
|
1278
1262
|
}
|
|
1279
1263
|
headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
|
|
1280
|
-
case
|
|
1264
|
+
case 31:
|
|
1281
1265
|
// If using server side decryption, specify in header
|
|
1282
1266
|
if (encrypted && !clientSideDecryption) {
|
|
1283
1267
|
headers["X-Content-Fabric-Decryption-Mode"] = "decrypt";
|
|
@@ -1286,46 +1270,46 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1286
1270
|
}
|
|
1287
1271
|
bytesTotal = fileInfo["."].size;
|
|
1288
1272
|
if (!(encrypted && clientSideDecryption)) {
|
|
1289
|
-
|
|
1273
|
+
_context16.next = 51;
|
|
1290
1274
|
break;
|
|
1291
1275
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1276
|
+
_context16.t5 = this;
|
|
1277
|
+
_context16.next = 37;
|
|
1294
1278
|
return this.EncryptionConk({
|
|
1295
1279
|
libraryId: libraryId,
|
|
1296
1280
|
objectId: objectId,
|
|
1297
1281
|
versionHash: versionHash,
|
|
1298
1282
|
download: true
|
|
1299
1283
|
});
|
|
1300
|
-
case
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
conk:
|
|
1311
|
-
downloadPath:
|
|
1312
|
-
bytesTotal:
|
|
1313
|
-
headers:
|
|
1314
|
-
callback:
|
|
1315
|
-
format:
|
|
1316
|
-
clientSideDecryption:
|
|
1317
|
-
chunked:
|
|
1284
|
+
case 37:
|
|
1285
|
+
_context16.t6 = _context16.sent;
|
|
1286
|
+
_context16.t7 = path;
|
|
1287
|
+
_context16.t8 = bytesTotal;
|
|
1288
|
+
_context16.t9 = headers;
|
|
1289
|
+
_context16.t10 = callback;
|
|
1290
|
+
_context16.t11 = format;
|
|
1291
|
+
_context16.t12 = clientSideDecryption;
|
|
1292
|
+
_context16.t13 = chunked;
|
|
1293
|
+
_context16.t14 = {
|
|
1294
|
+
conk: _context16.t6,
|
|
1295
|
+
downloadPath: _context16.t7,
|
|
1296
|
+
bytesTotal: _context16.t8,
|
|
1297
|
+
headers: _context16.t9,
|
|
1298
|
+
callback: _context16.t10,
|
|
1299
|
+
format: _context16.t11,
|
|
1300
|
+
clientSideDecryption: _context16.t12,
|
|
1301
|
+
chunked: _context16.t13
|
|
1318
1302
|
};
|
|
1319
|
-
|
|
1320
|
-
return
|
|
1321
|
-
case
|
|
1322
|
-
return
|
|
1323
|
-
case
|
|
1303
|
+
_context16.next = 48;
|
|
1304
|
+
return _context16.t5.DownloadEncrypted.call(_context16.t5, _context16.t14);
|
|
1305
|
+
case 48:
|
|
1306
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1307
|
+
case 51:
|
|
1324
1308
|
if (!chunkSize) {
|
|
1325
1309
|
chunkSize = 10000000;
|
|
1326
1310
|
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1311
|
+
_context16.prev = 52;
|
|
1312
|
+
_context16.next = 55;
|
|
1329
1313
|
return this.Download({
|
|
1330
1314
|
downloadPath: path,
|
|
1331
1315
|
bytesTotal: bytesTotal,
|
|
@@ -1335,28 +1319,28 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1335
1319
|
chunked: chunked,
|
|
1336
1320
|
chunkSize: chunkSize
|
|
1337
1321
|
});
|
|
1338
|
-
case
|
|
1339
|
-
return
|
|
1340
|
-
case
|
|
1341
|
-
|
|
1342
|
-
|
|
1322
|
+
case 55:
|
|
1323
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1324
|
+
case 58:
|
|
1325
|
+
_context16.prev = 58;
|
|
1326
|
+
_context16.t15 = _context16["catch"](52);
|
|
1343
1327
|
if (!(encrypted && !clientSideDecryption)) {
|
|
1344
|
-
|
|
1328
|
+
_context16.next = 62;
|
|
1345
1329
|
break;
|
|
1346
1330
|
}
|
|
1347
|
-
return
|
|
1331
|
+
return _context16.abrupt("return", this.DownloadFile(_objectSpread(_objectSpread({}, _args16[0]), {}, {
|
|
1348
1332
|
clientSideDecryption: true
|
|
1349
1333
|
})));
|
|
1350
|
-
case
|
|
1351
|
-
throw
|
|
1352
|
-
case
|
|
1334
|
+
case 62:
|
|
1335
|
+
throw _context16.t15;
|
|
1336
|
+
case 63:
|
|
1353
1337
|
case "end":
|
|
1354
|
-
return
|
|
1338
|
+
return _context16.stop();
|
|
1355
1339
|
}
|
|
1356
|
-
},
|
|
1340
|
+
}, _callee15, this, [[52, 58]]);
|
|
1357
1341
|
}));
|
|
1358
|
-
return function (
|
|
1359
|
-
return
|
|
1342
|
+
return function (_x16) {
|
|
1343
|
+
return _ref28.apply(this, arguments);
|
|
1360
1344
|
};
|
|
1361
1345
|
}();
|
|
1362
1346
|
|
|
@@ -1375,12 +1359,12 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1375
1359
|
* @returns {Promise<Object>} - Response containing list of parts of the object
|
|
1376
1360
|
*/
|
|
1377
1361
|
exports.ContentParts = /*#__PURE__*/function () {
|
|
1378
|
-
var
|
|
1379
|
-
var libraryId, objectId, versionHash, path, response
|
|
1380
|
-
return _regeneratorRuntime.wrap(function (
|
|
1381
|
-
while (1) switch (
|
|
1362
|
+
var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref29) {
|
|
1363
|
+
var libraryId, objectId, versionHash, path, response;
|
|
1364
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context17) {
|
|
1365
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1382
1366
|
case 0:
|
|
1383
|
-
libraryId =
|
|
1367
|
+
libraryId = _ref29.libraryId, objectId = _ref29.objectId, versionHash = _ref29.versionHash;
|
|
1384
1368
|
ValidateParameters({
|
|
1385
1369
|
libraryId: libraryId,
|
|
1386
1370
|
objectId: objectId,
|
|
@@ -1391,34 +1375,34 @@ exports.ContentParts = /*#__PURE__*/function () {
|
|
|
1391
1375
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1392
1376
|
}
|
|
1393
1377
|
path = UrlJoin("q", versionHash || objectId, "parts");
|
|
1394
|
-
|
|
1395
|
-
|
|
1378
|
+
_context17.t0 = this.HttpClient;
|
|
1379
|
+
_context17.next = 8;
|
|
1396
1380
|
return this.authClient.AuthorizationHeader({
|
|
1397
1381
|
libraryId: libraryId,
|
|
1398
1382
|
objectId: objectId,
|
|
1399
1383
|
versionHash: versionHash
|
|
1400
1384
|
});
|
|
1401
|
-
case
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
headers:
|
|
1385
|
+
case 8:
|
|
1386
|
+
_context17.t1 = _context17.sent;
|
|
1387
|
+
_context17.t2 = path;
|
|
1388
|
+
_context17.t3 = {
|
|
1389
|
+
headers: _context17.t1,
|
|
1406
1390
|
method: "GET",
|
|
1407
|
-
path:
|
|
1391
|
+
path: _context17.t2
|
|
1408
1392
|
};
|
|
1409
|
-
|
|
1410
|
-
return
|
|
1411
|
-
case
|
|
1412
|
-
response =
|
|
1413
|
-
return
|
|
1414
|
-
case
|
|
1393
|
+
_context17.next = 13;
|
|
1394
|
+
return _context17.t0.RequestJsonBody.call(_context17.t0, _context17.t3);
|
|
1395
|
+
case 13:
|
|
1396
|
+
response = _context17.sent;
|
|
1397
|
+
return _context17.abrupt("return", response.parts);
|
|
1398
|
+
case 15:
|
|
1415
1399
|
case "end":
|
|
1416
|
-
return
|
|
1400
|
+
return _context17.stop();
|
|
1417
1401
|
}
|
|
1418
|
-
},
|
|
1402
|
+
}, _callee16, this);
|
|
1419
1403
|
}));
|
|
1420
|
-
return function (
|
|
1421
|
-
return
|
|
1404
|
+
return function (_x17) {
|
|
1405
|
+
return _ref30.apply(this, arguments);
|
|
1422
1406
|
};
|
|
1423
1407
|
}();
|
|
1424
1408
|
|
|
@@ -1436,12 +1420,12 @@ exports.ContentParts = /*#__PURE__*/function () {
|
|
|
1436
1420
|
* @returns {Promise<Object>} - Response containing information about the specified part
|
|
1437
1421
|
*/
|
|
1438
1422
|
exports.ContentPart = /*#__PURE__*/function () {
|
|
1439
|
-
var
|
|
1440
|
-
var libraryId, objectId, versionHash, partHash, path
|
|
1441
|
-
return _regeneratorRuntime.wrap(function (
|
|
1442
|
-
while (1) switch (
|
|
1423
|
+
var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref31) {
|
|
1424
|
+
var libraryId, objectId, versionHash, partHash, path;
|
|
1425
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context18) {
|
|
1426
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1443
1427
|
case 0:
|
|
1444
|
-
libraryId =
|
|
1428
|
+
libraryId = _ref31.libraryId, objectId = _ref31.objectId, versionHash = _ref31.versionHash, partHash = _ref31.partHash;
|
|
1445
1429
|
ValidateParameters({
|
|
1446
1430
|
libraryId: libraryId,
|
|
1447
1431
|
objectId: objectId,
|
|
@@ -1453,33 +1437,33 @@ exports.ContentPart = /*#__PURE__*/function () {
|
|
|
1453
1437
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1454
1438
|
}
|
|
1455
1439
|
path = UrlJoin("q", versionHash || objectId, "parts", partHash);
|
|
1456
|
-
|
|
1457
|
-
|
|
1440
|
+
_context18.t0 = this.HttpClient;
|
|
1441
|
+
_context18.next = 9;
|
|
1458
1442
|
return this.authClient.AuthorizationHeader({
|
|
1459
1443
|
libraryId: libraryId,
|
|
1460
1444
|
objectId: objectId,
|
|
1461
1445
|
versionHash: versionHash
|
|
1462
1446
|
});
|
|
1463
|
-
case
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
headers:
|
|
1447
|
+
case 9:
|
|
1448
|
+
_context18.t1 = _context18.sent;
|
|
1449
|
+
_context18.t2 = path;
|
|
1450
|
+
_context18.t3 = {
|
|
1451
|
+
headers: _context18.t1,
|
|
1468
1452
|
method: "GET",
|
|
1469
|
-
path:
|
|
1453
|
+
path: _context18.t2
|
|
1470
1454
|
};
|
|
1471
|
-
|
|
1472
|
-
return
|
|
1473
|
-
case
|
|
1474
|
-
return
|
|
1475
|
-
case
|
|
1455
|
+
_context18.next = 14;
|
|
1456
|
+
return _context18.t0.RequestJsonBody.call(_context18.t0, _context18.t3);
|
|
1457
|
+
case 14:
|
|
1458
|
+
return _context18.abrupt("return", _context18.sent);
|
|
1459
|
+
case 15:
|
|
1476
1460
|
case "end":
|
|
1477
|
-
return
|
|
1461
|
+
return _context18.stop();
|
|
1478
1462
|
}
|
|
1479
|
-
},
|
|
1463
|
+
}, _callee17, this);
|
|
1480
1464
|
}));
|
|
1481
|
-
return function (
|
|
1482
|
-
return
|
|
1465
|
+
return function (_x18) {
|
|
1466
|
+
return _ref32.apply(this, arguments);
|
|
1483
1467
|
};
|
|
1484
1468
|
}();
|
|
1485
1469
|
|
|
@@ -1508,12 +1492,12 @@ exports.ContentPart = /*#__PURE__*/function () {
|
|
|
1508
1492
|
* @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, part data in the requested format otherwise
|
|
1509
1493
|
*/
|
|
1510
1494
|
exports.DownloadPart = /*#__PURE__*/function () {
|
|
1511
|
-
var
|
|
1512
|
-
var libraryId, objectId, versionHash, writeToken, partHash,
|
|
1513
|
-
return _regeneratorRuntime.wrap(function (
|
|
1514
|
-
while (1) switch (
|
|
1495
|
+
var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref33) {
|
|
1496
|
+
var libraryId, objectId, versionHash, writeToken, partHash, _ref33$format, format, _ref33$chunked, chunked, _ref33$chunkSize, chunkSize, callback, encrypted, encryption, path, headers, bytesTotal;
|
|
1497
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context19) {
|
|
1498
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1515
1499
|
case 0:
|
|
1516
|
-
libraryId =
|
|
1500
|
+
libraryId = _ref33.libraryId, objectId = _ref33.objectId, versionHash = _ref33.versionHash, writeToken = _ref33.writeToken, partHash = _ref33.partHash, _ref33$format = _ref33.format, format = _ref33$format === void 0 ? "arrayBuffer" : _ref33$format, _ref33$chunked = _ref33.chunked, chunked = _ref33$chunked === void 0 ? false : _ref33$chunked, _ref33$chunkSize = _ref33.chunkSize, chunkSize = _ref33$chunkSize === void 0 ? 10000000 : _ref33$chunkSize, callback = _ref33.callback;
|
|
1517
1501
|
ValidateParameters({
|
|
1518
1502
|
libraryId: libraryId,
|
|
1519
1503
|
objectId: objectId,
|
|
@@ -1526,7 +1510,7 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
1526
1510
|
encrypted = partHash.startsWith("hqpe");
|
|
1527
1511
|
encryption = encrypted ? "cgck" : undefined;
|
|
1528
1512
|
path = UrlJoin("q", writeToken || versionHash || objectId, "data", partHash);
|
|
1529
|
-
|
|
1513
|
+
_context19.next = 9;
|
|
1530
1514
|
return this.authClient.AuthorizationHeader({
|
|
1531
1515
|
libraryId: libraryId,
|
|
1532
1516
|
objectId: objectId,
|
|
@@ -1534,65 +1518,65 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
1534
1518
|
encryption: encryption,
|
|
1535
1519
|
makeAccessRequest: true
|
|
1536
1520
|
});
|
|
1537
|
-
case
|
|
1538
|
-
headers =
|
|
1539
|
-
|
|
1521
|
+
case 9:
|
|
1522
|
+
headers = _context19.sent;
|
|
1523
|
+
_context19.next = 12;
|
|
1540
1524
|
return this.ContentPart({
|
|
1541
1525
|
libraryId: libraryId,
|
|
1542
1526
|
objectId: objectId,
|
|
1543
1527
|
versionHash: versionHash,
|
|
1544
1528
|
partHash: partHash
|
|
1545
1529
|
});
|
|
1546
|
-
case
|
|
1547
|
-
bytesTotal =
|
|
1530
|
+
case 12:
|
|
1531
|
+
bytesTotal = _context19.sent.part.size;
|
|
1548
1532
|
if (!encrypted) {
|
|
1549
|
-
|
|
1533
|
+
_context19.next = 37;
|
|
1550
1534
|
break;
|
|
1551
1535
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1536
|
+
_context19.t0 = this.utils;
|
|
1537
|
+
_context19.t1 = this.signer.address;
|
|
1538
|
+
_context19.next = 18;
|
|
1555
1539
|
return this.ContentObjectOwner({
|
|
1556
1540
|
objectId: objectId
|
|
1557
1541
|
});
|
|
1558
|
-
case
|
|
1559
|
-
|
|
1560
|
-
if (
|
|
1561
|
-
|
|
1542
|
+
case 18:
|
|
1543
|
+
_context19.t2 = _context19.sent;
|
|
1544
|
+
if (_context19.t0.EqualAddress.call(_context19.t0, _context19.t1, _context19.t2)) {
|
|
1545
|
+
_context19.next = 21;
|
|
1562
1546
|
break;
|
|
1563
1547
|
}
|
|
1564
1548
|
headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
|
|
1565
|
-
case
|
|
1566
|
-
|
|
1567
|
-
|
|
1549
|
+
case 21:
|
|
1550
|
+
_context19.t3 = this;
|
|
1551
|
+
_context19.next = 24;
|
|
1568
1552
|
return this.EncryptionConk({
|
|
1569
1553
|
libraryId: libraryId,
|
|
1570
1554
|
objectId: objectId,
|
|
1571
1555
|
download: true
|
|
1572
1556
|
});
|
|
1573
|
-
case
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
conk:
|
|
1583
|
-
downloadPath:
|
|
1584
|
-
bytesTotal:
|
|
1585
|
-
headers:
|
|
1586
|
-
callback:
|
|
1587
|
-
format:
|
|
1588
|
-
chunked:
|
|
1557
|
+
case 24:
|
|
1558
|
+
_context19.t4 = _context19.sent;
|
|
1559
|
+
_context19.t5 = path;
|
|
1560
|
+
_context19.t6 = bytesTotal;
|
|
1561
|
+
_context19.t7 = headers;
|
|
1562
|
+
_context19.t8 = callback;
|
|
1563
|
+
_context19.t9 = format;
|
|
1564
|
+
_context19.t10 = chunked;
|
|
1565
|
+
_context19.t11 = {
|
|
1566
|
+
conk: _context19.t4,
|
|
1567
|
+
downloadPath: _context19.t5,
|
|
1568
|
+
bytesTotal: _context19.t6,
|
|
1569
|
+
headers: _context19.t7,
|
|
1570
|
+
callback: _context19.t8,
|
|
1571
|
+
format: _context19.t9,
|
|
1572
|
+
chunked: _context19.t10
|
|
1589
1573
|
};
|
|
1590
|
-
|
|
1591
|
-
return
|
|
1592
|
-
case
|
|
1593
|
-
return
|
|
1594
|
-
case
|
|
1595
|
-
|
|
1574
|
+
_context19.next = 34;
|
|
1575
|
+
return _context19.t3.DownloadEncrypted.call(_context19.t3, _context19.t11);
|
|
1576
|
+
case 34:
|
|
1577
|
+
return _context19.abrupt("return", _context19.sent);
|
|
1578
|
+
case 37:
|
|
1579
|
+
_context19.next = 39;
|
|
1596
1580
|
return this.Download({
|
|
1597
1581
|
downloadPath: path,
|
|
1598
1582
|
bytesTotal: bytesTotal,
|
|
@@ -1602,31 +1586,31 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
1602
1586
|
chunked: chunked,
|
|
1603
1587
|
chunkSize: chunkSize
|
|
1604
1588
|
});
|
|
1605
|
-
case
|
|
1606
|
-
return
|
|
1607
|
-
case
|
|
1589
|
+
case 39:
|
|
1590
|
+
return _context19.abrupt("return", _context19.sent);
|
|
1591
|
+
case 40:
|
|
1608
1592
|
case "end":
|
|
1609
|
-
return
|
|
1593
|
+
return _context19.stop();
|
|
1610
1594
|
}
|
|
1611
|
-
},
|
|
1595
|
+
}, _callee18, this);
|
|
1612
1596
|
}));
|
|
1613
|
-
return function (
|
|
1614
|
-
return
|
|
1597
|
+
return function (_x19) {
|
|
1598
|
+
return _ref34.apply(this, arguments);
|
|
1615
1599
|
};
|
|
1616
1600
|
}();
|
|
1617
1601
|
exports.Download = /*#__PURE__*/function () {
|
|
1618
|
-
var
|
|
1619
|
-
var downloadPath, headers, bytesTotal,
|
|
1620
|
-
return _regeneratorRuntime.wrap(function (
|
|
1621
|
-
while (1) switch (
|
|
1602
|
+
var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref35) {
|
|
1603
|
+
var downloadPath, headers, bytesTotal, _ref35$chunked, chunked, _ref35$chunkSize, chunkSize, callback, _ref35$format, format, outputChunks, bytesFinished, totalChunks, i, response;
|
|
1604
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context20) {
|
|
1605
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1622
1606
|
case 0:
|
|
1623
|
-
downloadPath =
|
|
1607
|
+
downloadPath = _ref35.downloadPath, headers = _ref35.headers, bytesTotal = _ref35.bytesTotal, _ref35$chunked = _ref35.chunked, chunked = _ref35$chunked === void 0 ? false : _ref35$chunked, _ref35$chunkSize = _ref35.chunkSize, chunkSize = _ref35$chunkSize === void 0 ? 2000000 : _ref35$chunkSize, callback = _ref35.callback, _ref35$format = _ref35.format, format = _ref35$format === void 0 ? "arrayBuffer" : _ref35$format;
|
|
1624
1608
|
if (!(chunked && !callback)) {
|
|
1625
|
-
|
|
1609
|
+
_context20.next = 3;
|
|
1626
1610
|
break;
|
|
1627
1611
|
}
|
|
1628
1612
|
throw Error("No callback specified for chunked download");
|
|
1629
|
-
case
|
|
1613
|
+
case 3:
|
|
1630
1614
|
if (!chunked) {
|
|
1631
1615
|
outputChunks = [];
|
|
1632
1616
|
}
|
|
@@ -1635,138 +1619,138 @@ exports.Download = /*#__PURE__*/function () {
|
|
|
1635
1619
|
bytesFinished = 0;
|
|
1636
1620
|
totalChunks = Math.ceil(bytesTotal / chunkSize);
|
|
1637
1621
|
i = 0;
|
|
1638
|
-
case
|
|
1622
|
+
case 7:
|
|
1639
1623
|
if (!(i < totalChunks)) {
|
|
1640
|
-
|
|
1624
|
+
_context20.next = 35;
|
|
1641
1625
|
break;
|
|
1642
1626
|
}
|
|
1643
1627
|
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
1644
|
-
|
|
1628
|
+
_context20.next = 11;
|
|
1645
1629
|
return this.HttpClient.Request({
|
|
1646
1630
|
path: downloadPath,
|
|
1647
1631
|
headers: headers,
|
|
1648
1632
|
method: "GET"
|
|
1649
1633
|
});
|
|
1650
|
-
case
|
|
1651
|
-
response =
|
|
1634
|
+
case 11:
|
|
1635
|
+
response = _context20.sent;
|
|
1652
1636
|
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
1653
1637
|
if (!chunked) {
|
|
1654
|
-
|
|
1638
|
+
_context20.next = 24;
|
|
1655
1639
|
break;
|
|
1656
1640
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1641
|
+
_context20.t0 = callback;
|
|
1642
|
+
_context20.t1 = bytesFinished;
|
|
1643
|
+
_context20.t2 = bytesTotal;
|
|
1644
|
+
_context20.next = 19;
|
|
1661
1645
|
return this.utils.ResponseToFormat(format, response);
|
|
1662
|
-
case
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
bytesFinished:
|
|
1666
|
-
bytesTotal:
|
|
1667
|
-
chunk:
|
|
1646
|
+
case 19:
|
|
1647
|
+
_context20.t3 = _context20.sent;
|
|
1648
|
+
_context20.t4 = {
|
|
1649
|
+
bytesFinished: _context20.t1,
|
|
1650
|
+
bytesTotal: _context20.t2,
|
|
1651
|
+
chunk: _context20.t3
|
|
1668
1652
|
};
|
|
1669
|
-
|
|
1670
|
-
|
|
1653
|
+
(0, _context20.t0)(_context20.t4);
|
|
1654
|
+
_context20.next = 32;
|
|
1671
1655
|
break;
|
|
1672
|
-
case
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1656
|
+
case 24:
|
|
1657
|
+
_context20.t5 = outputChunks;
|
|
1658
|
+
_context20.t6 = Buffer;
|
|
1659
|
+
_context20.next = 28;
|
|
1676
1660
|
return response.arrayBuffer();
|
|
1677
|
-
case
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1661
|
+
case 28:
|
|
1662
|
+
_context20.t7 = _context20.sent;
|
|
1663
|
+
_context20.t8 = _context20.t6.from.call(_context20.t6, _context20.t7);
|
|
1664
|
+
_context20.t5.push.call(_context20.t5, _context20.t8);
|
|
1681
1665
|
if (callback) {
|
|
1682
1666
|
callback({
|
|
1683
1667
|
bytesFinished: bytesFinished,
|
|
1684
1668
|
bytesTotal: bytesTotal
|
|
1685
1669
|
});
|
|
1686
1670
|
}
|
|
1687
|
-
case
|
|
1671
|
+
case 32:
|
|
1688
1672
|
i++;
|
|
1689
|
-
|
|
1673
|
+
_context20.next = 7;
|
|
1690
1674
|
break;
|
|
1691
|
-
case
|
|
1675
|
+
case 35:
|
|
1692
1676
|
if (chunked) {
|
|
1693
|
-
|
|
1677
|
+
_context20.next = 39;
|
|
1694
1678
|
break;
|
|
1695
1679
|
}
|
|
1696
|
-
|
|
1680
|
+
_context20.next = 38;
|
|
1697
1681
|
return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
|
|
1698
|
-
case
|
|
1699
|
-
return
|
|
1700
|
-
case
|
|
1682
|
+
case 38:
|
|
1683
|
+
return _context20.abrupt("return", _context20.sent);
|
|
1684
|
+
case 39:
|
|
1701
1685
|
case "end":
|
|
1702
|
-
return
|
|
1686
|
+
return _context20.stop();
|
|
1703
1687
|
}
|
|
1704
|
-
},
|
|
1688
|
+
}, _callee19, this);
|
|
1705
1689
|
}));
|
|
1706
|
-
return function (
|
|
1707
|
-
return
|
|
1690
|
+
return function (_x20) {
|
|
1691
|
+
return _ref36.apply(this, arguments);
|
|
1708
1692
|
};
|
|
1709
1693
|
}();
|
|
1710
1694
|
exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
1711
|
-
var
|
|
1695
|
+
var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref37) {
|
|
1712
1696
|
var _this2 = this;
|
|
1713
|
-
var conk, downloadPath, bytesTotal, headers, callback,
|
|
1714
|
-
return _regeneratorRuntime.wrap(function (
|
|
1715
|
-
while (1) switch (
|
|
1697
|
+
var conk, downloadPath, bytesTotal, headers, callback, _ref37$format, format, _ref37$chunked, chunked, isReencryption, chunkSize, bytesFinished, outputChunks, stream, totalChunks, i, response;
|
|
1698
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context22) {
|
|
1699
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1716
1700
|
case 0:
|
|
1717
|
-
conk =
|
|
1701
|
+
conk = _ref37.conk, downloadPath = _ref37.downloadPath, bytesTotal = _ref37.bytesTotal, headers = _ref37.headers, callback = _ref37.callback, _ref37$format = _ref37.format, format = _ref37$format === void 0 ? "arrayBuffer" : _ref37$format, _ref37$chunked = _ref37.chunked, chunked = _ref37$chunked === void 0 ? false : _ref37$chunked;
|
|
1718
1702
|
if (!(chunked && !callback)) {
|
|
1719
|
-
|
|
1703
|
+
_context22.next = 3;
|
|
1720
1704
|
break;
|
|
1721
1705
|
}
|
|
1722
1706
|
throw Error("No callback specified for chunked download");
|
|
1723
|
-
case
|
|
1707
|
+
case 3:
|
|
1724
1708
|
// Must align chunk size with encryption block size
|
|
1725
1709
|
isReencryption = conk.public_key.startsWith("ktpk");
|
|
1726
1710
|
chunkSize = this.Crypto.EncryptedBlockSize(1000000, isReencryption);
|
|
1727
1711
|
bytesFinished = 0;
|
|
1728
1712
|
format = format.toLowerCase();
|
|
1729
1713
|
outputChunks = []; // Set up decryption stream
|
|
1730
|
-
|
|
1714
|
+
_context22.next = 10;
|
|
1731
1715
|
return this.Crypto.OpenDecryptionStream(conk);
|
|
1732
|
-
case
|
|
1733
|
-
stream =
|
|
1716
|
+
case 10:
|
|
1717
|
+
stream = _context22.sent;
|
|
1734
1718
|
stream.on("data", /*#__PURE__*/function () {
|
|
1735
|
-
var
|
|
1719
|
+
var _ref39 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(chunk) {
|
|
1736
1720
|
var arrayBuffer;
|
|
1737
|
-
return _regeneratorRuntime.wrap(function (
|
|
1738
|
-
while (1) switch (
|
|
1721
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context21) {
|
|
1722
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1739
1723
|
case 0:
|
|
1740
1724
|
if (!chunked) {
|
|
1741
|
-
|
|
1725
|
+
_context21.next = 13;
|
|
1742
1726
|
break;
|
|
1743
1727
|
}
|
|
1744
1728
|
if (!(format !== "buffer")) {
|
|
1745
|
-
|
|
1729
|
+
_context21.next = 10;
|
|
1746
1730
|
break;
|
|
1747
1731
|
}
|
|
1748
1732
|
arrayBuffer = chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength);
|
|
1749
1733
|
if (!(format === "arraybuffer")) {
|
|
1750
|
-
|
|
1734
|
+
_context21.next = 7;
|
|
1751
1735
|
break;
|
|
1752
1736
|
}
|
|
1753
1737
|
chunk = arrayBuffer;
|
|
1754
|
-
|
|
1738
|
+
_context21.next = 10;
|
|
1755
1739
|
break;
|
|
1756
|
-
case
|
|
1757
|
-
|
|
1740
|
+
case 7:
|
|
1741
|
+
_context21.next = 9;
|
|
1758
1742
|
return _this2.utils.ResponseToFormat(format, new Response(arrayBuffer));
|
|
1759
|
-
case
|
|
1760
|
-
chunk =
|
|
1761
|
-
case
|
|
1743
|
+
case 9:
|
|
1744
|
+
chunk = _context21.sent;
|
|
1745
|
+
case 10:
|
|
1762
1746
|
callback({
|
|
1763
1747
|
bytesFinished: bytesFinished,
|
|
1764
1748
|
bytesTotal: bytesTotal,
|
|
1765
1749
|
chunk: chunk
|
|
1766
1750
|
});
|
|
1767
|
-
|
|
1751
|
+
_context21.next = 15;
|
|
1768
1752
|
break;
|
|
1769
|
-
case
|
|
1753
|
+
case 13:
|
|
1770
1754
|
if (callback) {
|
|
1771
1755
|
callback({
|
|
1772
1756
|
bytesFinished: bytesFinished,
|
|
@@ -1774,71 +1758,71 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
1774
1758
|
});
|
|
1775
1759
|
}
|
|
1776
1760
|
outputChunks.push(chunk);
|
|
1777
|
-
case
|
|
1761
|
+
case 15:
|
|
1778
1762
|
case "end":
|
|
1779
|
-
return
|
|
1763
|
+
return _context21.stop();
|
|
1780
1764
|
}
|
|
1781
|
-
},
|
|
1765
|
+
}, _callee20);
|
|
1782
1766
|
}));
|
|
1783
|
-
return function (
|
|
1784
|
-
return
|
|
1767
|
+
return function (_x22) {
|
|
1768
|
+
return _ref39.apply(this, arguments);
|
|
1785
1769
|
};
|
|
1786
1770
|
}());
|
|
1787
1771
|
totalChunks = Math.ceil(bytesTotal / chunkSize);
|
|
1788
1772
|
i = 0;
|
|
1789
|
-
case
|
|
1773
|
+
case 14:
|
|
1790
1774
|
if (!(i < totalChunks)) {
|
|
1791
|
-
|
|
1775
|
+
_context22.next = 30;
|
|
1792
1776
|
break;
|
|
1793
1777
|
}
|
|
1794
1778
|
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
1795
|
-
|
|
1779
|
+
_context22.next = 18;
|
|
1796
1780
|
return this.HttpClient.Request({
|
|
1797
1781
|
headers: headers,
|
|
1798
1782
|
method: "GET",
|
|
1799
1783
|
path: downloadPath
|
|
1800
1784
|
});
|
|
1801
|
-
case
|
|
1802
|
-
response =
|
|
1785
|
+
case 18:
|
|
1786
|
+
response = _context22.sent;
|
|
1803
1787
|
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1788
|
+
_context22.t0 = stream;
|
|
1789
|
+
_context22.t1 = Uint8Array;
|
|
1790
|
+
_context22.next = 24;
|
|
1807
1791
|
return response.arrayBuffer();
|
|
1808
|
-
case
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
case
|
|
1792
|
+
case 24:
|
|
1793
|
+
_context22.t2 = _context22.sent;
|
|
1794
|
+
_context22.t3 = new _context22.t1(_context22.t2);
|
|
1795
|
+
_context22.t0.write.call(_context22.t0, _context22.t3);
|
|
1796
|
+
case 27:
|
|
1813
1797
|
i++;
|
|
1814
|
-
|
|
1798
|
+
_context22.next = 14;
|
|
1815
1799
|
break;
|
|
1816
|
-
case
|
|
1800
|
+
case 30:
|
|
1817
1801
|
// Wait for decryption to complete
|
|
1818
1802
|
stream.end();
|
|
1819
|
-
|
|
1803
|
+
_context22.next = 33;
|
|
1820
1804
|
return new Promise(function (resolve) {
|
|
1821
1805
|
return stream.on("finish", function () {
|
|
1822
1806
|
resolve();
|
|
1823
1807
|
});
|
|
1824
1808
|
});
|
|
1825
|
-
case
|
|
1809
|
+
case 33:
|
|
1826
1810
|
if (chunked) {
|
|
1827
|
-
|
|
1811
|
+
_context22.next = 37;
|
|
1828
1812
|
break;
|
|
1829
1813
|
}
|
|
1830
|
-
|
|
1814
|
+
_context22.next = 36;
|
|
1831
1815
|
return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
|
|
1832
|
-
case
|
|
1833
|
-
return
|
|
1834
|
-
case
|
|
1816
|
+
case 36:
|
|
1817
|
+
return _context22.abrupt("return", _context22.sent);
|
|
1818
|
+
case 37:
|
|
1835
1819
|
case "end":
|
|
1836
|
-
return
|
|
1820
|
+
return _context22.stop();
|
|
1837
1821
|
}
|
|
1838
|
-
},
|
|
1822
|
+
}, _callee21, this);
|
|
1839
1823
|
}));
|
|
1840
|
-
return function (
|
|
1841
|
-
return
|
|
1824
|
+
return function (_x21) {
|
|
1825
|
+
return _ref38.apply(this, arguments);
|
|
1842
1826
|
};
|
|
1843
1827
|
}();
|
|
1844
1828
|
|
|
@@ -1856,50 +1840,50 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
1856
1840
|
* @returns {Promise<string>} - The part write token for the part draft
|
|
1857
1841
|
*/
|
|
1858
1842
|
exports.CreatePart = /*#__PURE__*/function () {
|
|
1859
|
-
var
|
|
1860
|
-
var libraryId, objectId, writeToken, encryption, path, openResponse
|
|
1861
|
-
return _regeneratorRuntime.wrap(function (
|
|
1862
|
-
while (1) switch (
|
|
1843
|
+
var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref40) {
|
|
1844
|
+
var libraryId, objectId, writeToken, encryption, path, openResponse;
|
|
1845
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context23) {
|
|
1846
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1863
1847
|
case 0:
|
|
1864
|
-
libraryId =
|
|
1848
|
+
libraryId = _ref40.libraryId, objectId = _ref40.objectId, writeToken = _ref40.writeToken, encryption = _ref40.encryption;
|
|
1865
1849
|
ValidateParameters({
|
|
1866
1850
|
libraryId: libraryId,
|
|
1867
1851
|
objectId: objectId
|
|
1868
1852
|
});
|
|
1869
1853
|
ValidateWriteToken(writeToken);
|
|
1870
1854
|
path = UrlJoin("q", writeToken, "parts");
|
|
1871
|
-
|
|
1872
|
-
|
|
1855
|
+
_context23.t0 = this.HttpClient;
|
|
1856
|
+
_context23.next = 7;
|
|
1873
1857
|
return this.authClient.AuthorizationHeader({
|
|
1874
1858
|
libraryId: libraryId,
|
|
1875
1859
|
objectId: objectId,
|
|
1876
1860
|
update: true,
|
|
1877
1861
|
encryption: encryption
|
|
1878
1862
|
});
|
|
1879
|
-
case
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
headers:
|
|
1863
|
+
case 7:
|
|
1864
|
+
_context23.t1 = _context23.sent;
|
|
1865
|
+
_context23.t2 = path;
|
|
1866
|
+
_context23.t3 = {
|
|
1867
|
+
headers: _context23.t1,
|
|
1884
1868
|
method: "POST",
|
|
1885
|
-
path:
|
|
1869
|
+
path: _context23.t2,
|
|
1886
1870
|
bodyType: "BINARY",
|
|
1887
1871
|
body: "",
|
|
1888
1872
|
allowFailover: false
|
|
1889
1873
|
};
|
|
1890
|
-
|
|
1891
|
-
return
|
|
1892
|
-
case
|
|
1893
|
-
openResponse =
|
|
1894
|
-
return
|
|
1895
|
-
case
|
|
1874
|
+
_context23.next = 12;
|
|
1875
|
+
return _context23.t0.RequestJsonBody.call(_context23.t0, _context23.t3);
|
|
1876
|
+
case 12:
|
|
1877
|
+
openResponse = _context23.sent;
|
|
1878
|
+
return _context23.abrupt("return", openResponse.part.write_token);
|
|
1879
|
+
case 14:
|
|
1896
1880
|
case "end":
|
|
1897
|
-
return
|
|
1881
|
+
return _context23.stop();
|
|
1898
1882
|
}
|
|
1899
|
-
},
|
|
1883
|
+
}, _callee22, this);
|
|
1900
1884
|
}));
|
|
1901
|
-
return function (
|
|
1902
|
-
return
|
|
1885
|
+
return function (_x23) {
|
|
1886
|
+
return _ref41.apply(this, arguments);
|
|
1903
1887
|
};
|
|
1904
1888
|
}();
|
|
1905
1889
|
|
|
@@ -1919,67 +1903,67 @@ exports.CreatePart = /*#__PURE__*/function () {
|
|
|
1919
1903
|
* @returns {Promise<string>} - The part write token for the part draft
|
|
1920
1904
|
*/
|
|
1921
1905
|
exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
1922
|
-
var
|
|
1923
|
-
var libraryId, objectId, writeToken, partWriteToken, chunk, encryption, conk, path
|
|
1924
|
-
return _regeneratorRuntime.wrap(function (
|
|
1925
|
-
while (1) switch (
|
|
1906
|
+
var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref42) {
|
|
1907
|
+
var libraryId, objectId, writeToken, partWriteToken, chunk, encryption, conk, path;
|
|
1908
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context24) {
|
|
1909
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1926
1910
|
case 0:
|
|
1927
|
-
libraryId =
|
|
1911
|
+
libraryId = _ref42.libraryId, objectId = _ref42.objectId, writeToken = _ref42.writeToken, partWriteToken = _ref42.partWriteToken, chunk = _ref42.chunk, encryption = _ref42.encryption;
|
|
1928
1912
|
ValidateParameters({
|
|
1929
1913
|
libraryId: libraryId,
|
|
1930
1914
|
objectId: objectId
|
|
1931
1915
|
});
|
|
1932
1916
|
ValidateWriteToken(writeToken);
|
|
1933
1917
|
if (!(encryption && encryption !== "none")) {
|
|
1934
|
-
|
|
1918
|
+
_context24.next = 10;
|
|
1935
1919
|
break;
|
|
1936
1920
|
}
|
|
1937
|
-
|
|
1921
|
+
_context24.next = 6;
|
|
1938
1922
|
return this.EncryptionConk({
|
|
1939
1923
|
libraryId: libraryId,
|
|
1940
1924
|
objectId: objectId,
|
|
1941
1925
|
writeToken: writeToken
|
|
1942
1926
|
});
|
|
1943
|
-
case
|
|
1944
|
-
conk =
|
|
1945
|
-
|
|
1927
|
+
case 6:
|
|
1928
|
+
conk = _context24.sent;
|
|
1929
|
+
_context24.next = 9;
|
|
1946
1930
|
return this.Crypto.Encrypt(conk, chunk);
|
|
1947
|
-
case
|
|
1948
|
-
chunk =
|
|
1949
|
-
case
|
|
1931
|
+
case 9:
|
|
1932
|
+
chunk = _context24.sent;
|
|
1933
|
+
case 10:
|
|
1950
1934
|
path = UrlJoin("q", writeToken, "parts");
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1935
|
+
_context24.t0 = this.utils;
|
|
1936
|
+
_context24.t1 = this.HttpClient;
|
|
1937
|
+
_context24.next = 15;
|
|
1954
1938
|
return this.authClient.AuthorizationHeader({
|
|
1955
1939
|
libraryId: libraryId,
|
|
1956
1940
|
objectId: objectId,
|
|
1957
1941
|
update: true,
|
|
1958
1942
|
encryption: encryption
|
|
1959
1943
|
});
|
|
1960
|
-
case
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
headers:
|
|
1944
|
+
case 15:
|
|
1945
|
+
_context24.t2 = _context24.sent;
|
|
1946
|
+
_context24.t3 = UrlJoin(path, partWriteToken);
|
|
1947
|
+
_context24.t4 = chunk;
|
|
1948
|
+
_context24.t5 = {
|
|
1949
|
+
headers: _context24.t2,
|
|
1966
1950
|
method: "POST",
|
|
1967
|
-
path:
|
|
1968
|
-
body:
|
|
1951
|
+
path: _context24.t3,
|
|
1952
|
+
body: _context24.t4,
|
|
1969
1953
|
bodyType: "BINARY",
|
|
1970
1954
|
allowFailover: false
|
|
1971
1955
|
};
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
return
|
|
1975
|
-
case
|
|
1956
|
+
_context24.t6 = _context24.t1.Request.call(_context24.t1, _context24.t5);
|
|
1957
|
+
_context24.next = 22;
|
|
1958
|
+
return _context24.t0.ResponseToJson.call(_context24.t0, _context24.t6);
|
|
1959
|
+
case 22:
|
|
1976
1960
|
case "end":
|
|
1977
|
-
return
|
|
1961
|
+
return _context24.stop();
|
|
1978
1962
|
}
|
|
1979
|
-
},
|
|
1963
|
+
}, _callee23, this);
|
|
1980
1964
|
}));
|
|
1981
|
-
return function (
|
|
1982
|
-
return
|
|
1965
|
+
return function (_x24) {
|
|
1966
|
+
return _ref43.apply(this, arguments);
|
|
1983
1967
|
};
|
|
1984
1968
|
}();
|
|
1985
1969
|
|
|
@@ -1998,49 +1982,49 @@ exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
|
1998
1982
|
* @returns {Promise<object>} - The finalize response for the new part
|
|
1999
1983
|
*/
|
|
2000
1984
|
exports.FinalizePart = /*#__PURE__*/function () {
|
|
2001
|
-
var
|
|
2002
|
-
var libraryId, objectId, writeToken, partWriteToken, encryption, path
|
|
2003
|
-
return _regeneratorRuntime.wrap(function (
|
|
2004
|
-
while (1) switch (
|
|
1985
|
+
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref44) {
|
|
1986
|
+
var libraryId, objectId, writeToken, partWriteToken, encryption, path;
|
|
1987
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context25) {
|
|
1988
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2005
1989
|
case 0:
|
|
2006
|
-
libraryId =
|
|
1990
|
+
libraryId = _ref44.libraryId, objectId = _ref44.objectId, writeToken = _ref44.writeToken, partWriteToken = _ref44.partWriteToken, encryption = _ref44.encryption;
|
|
2007
1991
|
ValidateParameters({
|
|
2008
1992
|
libraryId: libraryId,
|
|
2009
1993
|
objectId: objectId
|
|
2010
1994
|
});
|
|
2011
1995
|
ValidateWriteToken(writeToken);
|
|
2012
1996
|
path = UrlJoin("q", writeToken, "parts");
|
|
2013
|
-
|
|
2014
|
-
|
|
1997
|
+
_context25.t0 = this.HttpClient;
|
|
1998
|
+
_context25.next = 7;
|
|
2015
1999
|
return this.authClient.AuthorizationHeader({
|
|
2016
2000
|
libraryId: libraryId,
|
|
2017
2001
|
objectId: objectId,
|
|
2018
2002
|
update: true,
|
|
2019
2003
|
encryption: encryption
|
|
2020
2004
|
});
|
|
2021
|
-
case
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
headers:
|
|
2005
|
+
case 7:
|
|
2006
|
+
_context25.t1 = _context25.sent;
|
|
2007
|
+
_context25.t2 = UrlJoin(path, partWriteToken);
|
|
2008
|
+
_context25.t3 = {
|
|
2009
|
+
headers: _context25.t1,
|
|
2026
2010
|
method: "POST",
|
|
2027
|
-
path:
|
|
2011
|
+
path: _context25.t2,
|
|
2028
2012
|
bodyType: "BINARY",
|
|
2029
2013
|
body: "",
|
|
2030
2014
|
allowFailover: false
|
|
2031
2015
|
};
|
|
2032
|
-
|
|
2033
|
-
return
|
|
2034
|
-
case
|
|
2035
|
-
return
|
|
2036
|
-
case
|
|
2016
|
+
_context25.next = 12;
|
|
2017
|
+
return _context25.t0.RequestJsonBody.call(_context25.t0, _context25.t3);
|
|
2018
|
+
case 12:
|
|
2019
|
+
return _context25.abrupt("return", _context25.sent);
|
|
2020
|
+
case 13:
|
|
2037
2021
|
case "end":
|
|
2038
|
-
return
|
|
2022
|
+
return _context25.stop();
|
|
2039
2023
|
}
|
|
2040
|
-
},
|
|
2024
|
+
}, _callee24, this);
|
|
2041
2025
|
}));
|
|
2042
|
-
return function (
|
|
2043
|
-
return
|
|
2026
|
+
return function (_x25) {
|
|
2027
|
+
return _ref45.apply(this, arguments);
|
|
2044
2028
|
};
|
|
2045
2029
|
}();
|
|
2046
2030
|
|
|
@@ -2066,26 +2050,26 @@ exports.FinalizePart = /*#__PURE__*/function () {
|
|
|
2066
2050
|
* @returns {Promise<Object>} - Response containing information about the uploaded part
|
|
2067
2051
|
*/
|
|
2068
2052
|
exports.UploadPart = /*#__PURE__*/function () {
|
|
2069
|
-
var
|
|
2070
|
-
var libraryId, objectId, writeToken, data,
|
|
2071
|
-
return _regeneratorRuntime.wrap(function (
|
|
2072
|
-
while (1) switch (
|
|
2053
|
+
var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref46) {
|
|
2054
|
+
var libraryId, objectId, writeToken, data, _ref46$encryption, encryption, _ref46$chunkSize, chunkSize, callback, partWriteToken, size, i, chunk;
|
|
2055
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context26) {
|
|
2056
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2073
2057
|
case 0:
|
|
2074
|
-
libraryId =
|
|
2058
|
+
libraryId = _ref46.libraryId, objectId = _ref46.objectId, writeToken = _ref46.writeToken, data = _ref46.data, _ref46$encryption = _ref46.encryption, encryption = _ref46$encryption === void 0 ? "none" : _ref46$encryption, _ref46$chunkSize = _ref46.chunkSize, chunkSize = _ref46$chunkSize === void 0 ? 10000000 : _ref46$chunkSize, callback = _ref46.callback;
|
|
2075
2059
|
ValidateParameters({
|
|
2076
2060
|
libraryId: libraryId,
|
|
2077
2061
|
objectId: objectId
|
|
2078
2062
|
});
|
|
2079
2063
|
ValidateWriteToken(writeToken);
|
|
2080
|
-
|
|
2064
|
+
_context26.next = 5;
|
|
2081
2065
|
return this.CreatePart({
|
|
2082
2066
|
libraryId: libraryId,
|
|
2083
2067
|
objectId: objectId,
|
|
2084
2068
|
writeToken: writeToken,
|
|
2085
2069
|
encryption: encryption
|
|
2086
2070
|
});
|
|
2087
|
-
case
|
|
2088
|
-
partWriteToken =
|
|
2071
|
+
case 5:
|
|
2072
|
+
partWriteToken = _context26.sent;
|
|
2089
2073
|
size = data.length || data.byteLength || data.size;
|
|
2090
2074
|
if (callback) {
|
|
2091
2075
|
callback({
|
|
@@ -2094,13 +2078,13 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2094
2078
|
});
|
|
2095
2079
|
}
|
|
2096
2080
|
i = 0;
|
|
2097
|
-
case
|
|
2081
|
+
case 9:
|
|
2098
2082
|
if (!(i < size)) {
|
|
2099
|
-
|
|
2083
|
+
_context26.next = 17;
|
|
2100
2084
|
break;
|
|
2101
2085
|
}
|
|
2102
2086
|
chunk = data.slice(i, i + chunkSize);
|
|
2103
|
-
|
|
2087
|
+
_context26.next = 13;
|
|
2104
2088
|
return this.UploadPartChunk({
|
|
2105
2089
|
libraryId: libraryId,
|
|
2106
2090
|
objectId: objectId,
|
|
@@ -2109,19 +2093,19 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2109
2093
|
chunk: chunk,
|
|
2110
2094
|
encryption: encryption
|
|
2111
2095
|
});
|
|
2112
|
-
case
|
|
2096
|
+
case 13:
|
|
2113
2097
|
if (callback) {
|
|
2114
2098
|
callback({
|
|
2115
2099
|
bytesFinished: Math.min(i + chunkSize, size),
|
|
2116
2100
|
bytesTotal: size
|
|
2117
2101
|
});
|
|
2118
2102
|
}
|
|
2119
|
-
case
|
|
2103
|
+
case 14:
|
|
2120
2104
|
i += chunkSize;
|
|
2121
|
-
|
|
2105
|
+
_context26.next = 9;
|
|
2122
2106
|
break;
|
|
2123
|
-
case
|
|
2124
|
-
|
|
2107
|
+
case 17:
|
|
2108
|
+
_context26.next = 19;
|
|
2125
2109
|
return this.FinalizePart({
|
|
2126
2110
|
libraryId: libraryId,
|
|
2127
2111
|
objectId: objectId,
|
|
@@ -2129,16 +2113,16 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2129
2113
|
partWriteToken: partWriteToken,
|
|
2130
2114
|
encryption: encryption
|
|
2131
2115
|
});
|
|
2132
|
-
case
|
|
2133
|
-
return
|
|
2134
|
-
case
|
|
2116
|
+
case 19:
|
|
2117
|
+
return _context26.abrupt("return", _context26.sent);
|
|
2118
|
+
case 20:
|
|
2135
2119
|
case "end":
|
|
2136
|
-
return
|
|
2120
|
+
return _context26.stop();
|
|
2137
2121
|
}
|
|
2138
|
-
},
|
|
2122
|
+
}, _callee25, this);
|
|
2139
2123
|
}));
|
|
2140
|
-
return function (
|
|
2141
|
-
return
|
|
2124
|
+
return function (_x26) {
|
|
2125
|
+
return _ref47.apply(this, arguments);
|
|
2142
2126
|
};
|
|
2143
2127
|
}();
|
|
2144
2128
|
|
|
@@ -2154,12 +2138,12 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2154
2138
|
* @param {string} partHash - Hash of the part to delete
|
|
2155
2139
|
*/
|
|
2156
2140
|
exports.DeletePart = /*#__PURE__*/function () {
|
|
2157
|
-
var
|
|
2158
|
-
var libraryId, objectId, writeToken, partHash, path
|
|
2159
|
-
return _regeneratorRuntime.wrap(function (
|
|
2160
|
-
while (1) switch (
|
|
2141
|
+
var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref48) {
|
|
2142
|
+
var libraryId, objectId, writeToken, partHash, path;
|
|
2143
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context27) {
|
|
2144
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2161
2145
|
case 0:
|
|
2162
|
-
libraryId =
|
|
2146
|
+
libraryId = _ref48.libraryId, objectId = _ref48.objectId, writeToken = _ref48.writeToken, partHash = _ref48.partHash;
|
|
2163
2147
|
ValidateParameters({
|
|
2164
2148
|
libraryId: libraryId,
|
|
2165
2149
|
objectId: objectId
|
|
@@ -2167,31 +2151,31 @@ exports.DeletePart = /*#__PURE__*/function () {
|
|
|
2167
2151
|
ValidateWriteToken(writeToken);
|
|
2168
2152
|
ValidatePartHash(partHash);
|
|
2169
2153
|
path = UrlJoin("q", writeToken, "parts", partHash);
|
|
2170
|
-
|
|
2171
|
-
|
|
2154
|
+
_context27.t0 = this.HttpClient;
|
|
2155
|
+
_context27.next = 8;
|
|
2172
2156
|
return this.authClient.AuthorizationHeader({
|
|
2173
2157
|
libraryId: libraryId,
|
|
2174
2158
|
objectId: objectId,
|
|
2175
2159
|
update: true
|
|
2176
2160
|
});
|
|
2177
|
-
case
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
headers:
|
|
2161
|
+
case 8:
|
|
2162
|
+
_context27.t1 = _context27.sent;
|
|
2163
|
+
_context27.t2 = path;
|
|
2164
|
+
_context27.t3 = {
|
|
2165
|
+
headers: _context27.t1,
|
|
2182
2166
|
method: "DELETE",
|
|
2183
|
-
path:
|
|
2167
|
+
path: _context27.t2,
|
|
2184
2168
|
allowFailover: false
|
|
2185
2169
|
};
|
|
2186
|
-
|
|
2187
|
-
return
|
|
2188
|
-
case
|
|
2170
|
+
_context27.next = 13;
|
|
2171
|
+
return _context27.t0.Request.call(_context27.t0, _context27.t3);
|
|
2172
|
+
case 13:
|
|
2189
2173
|
case "end":
|
|
2190
|
-
return
|
|
2174
|
+
return _context27.stop();
|
|
2191
2175
|
}
|
|
2192
|
-
},
|
|
2176
|
+
}, _callee26, this);
|
|
2193
2177
|
}));
|
|
2194
|
-
return function (
|
|
2195
|
-
return
|
|
2178
|
+
return function (_x27) {
|
|
2179
|
+
return _ref49.apply(this, arguments);
|
|
2196
2180
|
};
|
|
2197
2181
|
}();
|