@eluvio/elv-client-js 4.2.12 → 4.2.13
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 +710 -723
- package/dist/src/ContentObjectAudit.js +56 -56
- package/dist/src/Crypto.js +85 -85
- package/dist/src/ElvClient.js +530 -500
- package/dist/src/ElvWallet.js +30 -28
- package/dist/src/EthClient.js +311 -311
- package/dist/src/FrameClient.js +63 -64
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +1 -2
- package/dist/src/PermissionsClient.js +499 -487
- package/dist/src/RemoteSigner.js +114 -163
- package/dist/src/UserProfileClient.js +392 -374
- package/dist/src/Utils.js +69 -66
- package/dist/src/Validation.js +10 -10
- package/dist/src/client/ABRPublishing.js +238 -238
- package/dist/src/client/AccessGroups.js +477 -474
- package/dist/src/client/ContentAccess.js +1707 -1711
- package/dist/src/client/ContentManagement.js +871 -871
- package/dist/src/client/Contracts.js +575 -578
- package/dist/src/client/Files.js +700 -684
- package/dist/src/client/LiveConf.js +1 -6
- package/dist/src/client/LiveStream.js +722 -686
- package/dist/src/client/NFT.js +14 -14
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +53 -60
- package/dist/src/walletClient/ClientMethods.js +977 -951
- 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 +579 -581
- package/package.json +1 -1
- package/src/client/ContentAccess.js +1 -1
- package/dist/src/ContentObjectVerification.js +0 -281
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(
|
|
44
|
-
var libraryId, objectId, _ref$path, path, versionHash, writeToken, urlPath;
|
|
45
|
-
return _regeneratorRuntime.wrap(function
|
|
43
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
44
|
+
var libraryId, objectId, _ref$path, path, versionHash, writeToken, urlPath, _t, _t2, _t3, _t4;
|
|
45
|
+
return _regeneratorRuntime.wrap(function (_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
|
+
_t = this.HttpClient;
|
|
60
|
+
_context.next = 1;
|
|
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 1:
|
|
67
|
+
_t2 = _context.sent;
|
|
68
|
+
_t3 = urlPath;
|
|
69
|
+
_t4 = {
|
|
70
|
+
headers: _t2,
|
|
71
71
|
method: "GET",
|
|
72
|
-
path:
|
|
72
|
+
path: _t3
|
|
73
73
|
};
|
|
74
|
-
return _context.abrupt("return",
|
|
75
|
-
case
|
|
74
|
+
return _context.abrupt("return", _t.RequestJsonBody.call(_t, _t4));
|
|
75
|
+
case 2:
|
|
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(
|
|
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
|
|
123
|
+
return _regeneratorRuntime.wrap(function (_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 1:
|
|
136
136
|
if (!(i < fileInfo.length)) {
|
|
137
|
-
_context2.next =
|
|
137
|
+
_context2.next = 4;
|
|
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 = 3;
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
146
|
bucketName = s3prefixMatch[1];
|
|
147
147
|
if (!(bucketName !== bucket)) {
|
|
148
|
-
_context2.next =
|
|
148
|
+
_context2.next = 2;
|
|
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 2:
|
|
153
153
|
// strip prefix
|
|
154
154
|
fileInfo[i].source = fileSourcePath.replace(s3prefixRegex, "");
|
|
155
|
-
case
|
|
155
|
+
case 3:
|
|
156
156
|
i++;
|
|
157
|
-
_context2.next =
|
|
157
|
+
_context2.next = 1;
|
|
158
158
|
break;
|
|
159
|
-
case
|
|
159
|
+
case 4:
|
|
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 = 6;
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
|
-
_context2.next =
|
|
169
|
+
_context2.next = 5;
|
|
170
170
|
return this.EncryptionConk({
|
|
171
171
|
libraryId: libraryId,
|
|
172
172
|
objectId: objectId,
|
|
173
173
|
writeToken: writeToken
|
|
174
174
|
});
|
|
175
|
-
case
|
|
175
|
+
case 5:
|
|
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 6:
|
|
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 = 7;
|
|
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 7:
|
|
236
236
|
_yield$this$CreateFil = _context2.sent;
|
|
237
237
|
id = _yield$this$CreateFil.id;
|
|
238
|
-
case
|
|
238
|
+
case 8:
|
|
239
239
|
if (!true) {
|
|
240
|
-
_context2.next =
|
|
240
|
+
_context2.next = 15;
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
|
-
_context2.next =
|
|
243
|
+
_context2.next = 9;
|
|
244
244
|
return new Promise(function (resolve) {
|
|
245
245
|
return setTimeout(resolve, 1000);
|
|
246
246
|
});
|
|
247
|
-
case
|
|
248
|
-
_context2.next =
|
|
247
|
+
case 9:
|
|
248
|
+
_context2.next = 10;
|
|
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 10:
|
|
256
256
|
status = _context2.sent;
|
|
257
257
|
if (!(status.errors && status.errors.length > 1)) {
|
|
258
|
-
_context2.next =
|
|
258
|
+
_context2.next = 11;
|
|
259
259
|
break;
|
|
260
260
|
}
|
|
261
261
|
throw status.errors.join("\n");
|
|
262
|
-
case
|
|
262
|
+
case 11:
|
|
263
263
|
if (!status.error) {
|
|
264
|
-
_context2.next =
|
|
264
|
+
_context2.next = 12;
|
|
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 12:
|
|
270
270
|
if (!(status.status.toLowerCase() === "failed")) {
|
|
271
|
-
_context2.next =
|
|
271
|
+
_context2.next = 13;
|
|
272
272
|
break;
|
|
273
273
|
}
|
|
274
274
|
throw "File upload failed";
|
|
275
|
-
case
|
|
275
|
+
case 13:
|
|
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 = 14;
|
|
303
303
|
break;
|
|
304
304
|
}
|
|
305
|
-
return _context2.abrupt("
|
|
306
|
-
case
|
|
307
|
-
_context2.next =
|
|
305
|
+
return _context2.abrupt("continue", 15);
|
|
306
|
+
case 14:
|
|
307
|
+
_context2.next = 8;
|
|
308
308
|
break;
|
|
309
|
-
case
|
|
309
|
+
case 15:
|
|
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(
|
|
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
|
|
350
|
+
return _regeneratorRuntime.wrap(function (_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 = 2;
|
|
363
363
|
break;
|
|
364
364
|
}
|
|
365
|
-
_context7.next =
|
|
365
|
+
_context7.next = 1;
|
|
366
366
|
return this.EncryptionConk({
|
|
367
367
|
libraryId: libraryId,
|
|
368
368
|
objectId: objectId,
|
|
369
369
|
writeToken: writeToken
|
|
370
370
|
});
|
|
371
|
-
case
|
|
371
|
+
case 1:
|
|
372
372
|
conk = _context7.sent;
|
|
373
|
-
case
|
|
373
|
+
case 2:
|
|
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 = 3;
|
|
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 3:
|
|
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(
|
|
422
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
423
423
|
var j, jobId, job, f, _fileInfo, data;
|
|
424
|
-
return _regeneratorRuntime.wrap(function
|
|
424
|
+
return _regeneratorRuntime.wrap(function (_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 = 12;
|
|
431
431
|
break;
|
|
432
432
|
}
|
|
433
433
|
case 2:
|
|
434
434
|
if (!(prepared - uploaded > bufferSize)) {
|
|
435
|
-
_context3.next =
|
|
435
|
+
_context3.next = 4;
|
|
436
436
|
break;
|
|
437
437
|
}
|
|
438
|
-
_context3.next =
|
|
438
|
+
_context3.next = 3;
|
|
439
439
|
return new Promise(function (resolve) {
|
|
440
440
|
return setTimeout(resolve, 500);
|
|
441
441
|
});
|
|
442
|
-
case
|
|
442
|
+
case 3:
|
|
443
443
|
_context3.next = 2;
|
|
444
444
|
break;
|
|
445
|
-
case
|
|
445
|
+
case 4:
|
|
446
446
|
// Retrieve job info
|
|
447
447
|
jobId = jobs[j];
|
|
448
|
-
_context3.next =
|
|
448
|
+
_context3.next = 5;
|
|
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 5:
|
|
457
457
|
job = _context3.sent;
|
|
458
458
|
f = 0;
|
|
459
|
-
case
|
|
459
|
+
case 6:
|
|
460
460
|
if (!(f < job.files.length)) {
|
|
461
|
-
_context3.next =
|
|
461
|
+
_context3.next = 10;
|
|
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 = 8;
|
|
476
476
|
break;
|
|
477
477
|
}
|
|
478
|
-
_context3.next =
|
|
478
|
+
_context3.next = 7;
|
|
479
479
|
return _this.Crypto.Encrypt(conk, data);
|
|
480
|
-
case
|
|
480
|
+
case 7:
|
|
481
481
|
data = _context3.sent;
|
|
482
|
-
case
|
|
482
|
+
case 8:
|
|
483
483
|
job.files[f].data = data;
|
|
484
484
|
prepared += _fileInfo.len;
|
|
485
|
-
case
|
|
485
|
+
case 9:
|
|
486
486
|
f++;
|
|
487
|
-
_context3.next =
|
|
487
|
+
_context3.next = 6;
|
|
488
488
|
break;
|
|
489
|
-
case
|
|
489
|
+
case 10:
|
|
490
490
|
jobSpecs[j] = job;
|
|
491
491
|
|
|
492
492
|
// Wait for a bit to let upload start
|
|
493
|
-
_context3.next =
|
|
493
|
+
_context3.next = 11;
|
|
494
494
|
return new Promise(function (resolve) {
|
|
495
495
|
return setTimeout(resolve, 50);
|
|
496
496
|
});
|
|
497
|
-
case
|
|
497
|
+
case 11:
|
|
498
498
|
j++;
|
|
499
499
|
_context3.next = 1;
|
|
500
500
|
break;
|
|
501
|
-
case
|
|
501
|
+
case 12:
|
|
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(
|
|
512
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobId, j) {
|
|
513
513
|
var jobSpec, files, _loop, f;
|
|
514
|
-
return _regeneratorRuntime.wrap(function
|
|
514
|
+
return _regeneratorRuntime.wrap(function (_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 = 2;
|
|
519
519
|
break;
|
|
520
520
|
}
|
|
521
|
-
_context5.next =
|
|
521
|
+
_context5.next = 1;
|
|
522
522
|
return new Promise(function (resolve) {
|
|
523
523
|
return setTimeout(resolve, 500);
|
|
524
524
|
});
|
|
525
|
-
case
|
|
525
|
+
case 1:
|
|
526
526
|
_context5.next = 0;
|
|
527
527
|
break;
|
|
528
|
-
case
|
|
528
|
+
case 2:
|
|
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
|
|
532
|
+
var fileInfo, retries, succeeded, _t5;
|
|
533
|
+
return _regeneratorRuntime.wrap(function (_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 1:
|
|
540
|
+
_context4.prev = 1;
|
|
541
|
+
_context4.next = 2;
|
|
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 2:
|
|
553
553
|
succeeded = true;
|
|
554
|
-
_context4.next =
|
|
554
|
+
_context4.next = 5;
|
|
555
555
|
break;
|
|
556
|
-
case
|
|
557
|
-
_context4.prev =
|
|
558
|
-
|
|
559
|
-
_this.Log(
|
|
556
|
+
case 3:
|
|
557
|
+
_context4.prev = 3;
|
|
558
|
+
_t5 = _context4["catch"](1);
|
|
559
|
+
_this.Log(_t5, true);
|
|
560
560
|
retries += 1;
|
|
561
561
|
if (!(retries >= 10)) {
|
|
562
|
-
_context4.next =
|
|
562
|
+
_context4.next = 4;
|
|
563
563
|
break;
|
|
564
564
|
}
|
|
565
|
-
throw
|
|
566
|
-
case
|
|
567
|
-
_context4.next =
|
|
565
|
+
throw _t5;
|
|
566
|
+
case 4:
|
|
567
|
+
_context4.next = 5;
|
|
568
568
|
return new Promise(function (resolve) {
|
|
569
569
|
return setTimeout(resolve, 10 * retries * 1000);
|
|
570
570
|
});
|
|
571
|
-
case
|
|
571
|
+
case 5:
|
|
572
572
|
if (!succeeded && retries < 10) {
|
|
573
|
-
_context4.next =
|
|
573
|
+
_context4.next = 1;
|
|
574
574
|
break;
|
|
575
575
|
}
|
|
576
|
-
case
|
|
576
|
+
case 6:
|
|
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 7:
|
|
586
586
|
case "end":
|
|
587
587
|
return _context4.stop();
|
|
588
588
|
}
|
|
589
|
-
}, _loop, null, [[
|
|
589
|
+
}, _loop, null, [[1, 3]]);
|
|
590
590
|
});
|
|
591
591
|
f = 0;
|
|
592
|
-
case
|
|
592
|
+
case 3:
|
|
593
593
|
if (!(f < files.length)) {
|
|
594
|
-
_context5.next =
|
|
594
|
+
_context5.next = 5;
|
|
595
595
|
break;
|
|
596
596
|
}
|
|
597
|
-
return _context5.delegateYield(_loop(), "t0",
|
|
598
|
-
case
|
|
597
|
+
return _context5.delegateYield(_loop(), "t0", 4);
|
|
598
|
+
case 4:
|
|
599
599
|
f++;
|
|
600
|
-
_context5.next =
|
|
600
|
+
_context5.next = 3;
|
|
601
601
|
break;
|
|
602
|
-
case
|
|
602
|
+
case 5:
|
|
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 4:
|
|
621
621
|
if (!(j < rateTestJobs)) {
|
|
622
|
-
_context7.next =
|
|
622
|
+
_context7.next = 7;
|
|
623
623
|
break;
|
|
624
624
|
}
|
|
625
625
|
start = new Date().getTime();
|
|
626
|
-
_context7.next =
|
|
626
|
+
_context7.next = 5;
|
|
627
627
|
return UploadJob(jobs[j], j);
|
|
628
|
-
case
|
|
628
|
+
case 5:
|
|
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 6:
|
|
637
637
|
j++;
|
|
638
|
-
_context7.next =
|
|
638
|
+
_context7.next = 4;
|
|
639
639
|
break;
|
|
640
|
-
case
|
|
640
|
+
case 7:
|
|
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 = 8;
|
|
646
646
|
return this.utils.LimitedMap(concurrentUploads, jobs, /*#__PURE__*/function () {
|
|
647
|
-
var _ref9 = _asyncToGenerator(
|
|
648
|
-
return _regeneratorRuntime.wrap(function
|
|
647
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(jobId, j) {
|
|
648
|
+
return _regeneratorRuntime.wrap(function (_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 = 1;
|
|
653
653
|
break;
|
|
654
654
|
}
|
|
655
655
|
return _context6.abrupt("return");
|
|
656
|
-
case
|
|
657
|
-
_context6.next =
|
|
656
|
+
case 1:
|
|
657
|
+
_context6.next = 2;
|
|
658
658
|
return UploadJob(jobId, j);
|
|
659
|
-
case
|
|
659
|
+
case 2:
|
|
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 8:
|
|
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
|
|
680
|
+
var _ref1 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref0) {
|
|
681
|
+
var libraryId, objectId, writeToken, ops, _ref0$defaults, defaults, _ref0$encryption, encryption, body, path, _t6, _t7, _t8, _t9, _t0;
|
|
682
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
683
683
|
while (1) switch (_context8.prev = _context8.next) {
|
|
684
684
|
case 0:
|
|
685
|
-
libraryId =
|
|
685
|
+
libraryId = _ref0.libraryId, objectId = _ref0.objectId, writeToken = _ref0.writeToken, ops = _ref0.ops, _ref0$defaults = _ref0.defaults, defaults = _ref0$defaults === void 0 ? {} : _ref0$defaults, _ref0$encryption = _ref0.encryption, encryption = _ref0$encryption === void 0 ? "none" : _ref0$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
|
+
_t6 = this.HttpClient;
|
|
706
|
+
_context8.next = 1;
|
|
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 1:
|
|
714
|
+
_t7 = _context8.sent;
|
|
715
|
+
_t8 = path;
|
|
716
|
+
_t9 = body;
|
|
717
|
+
_t0 = {
|
|
718
|
+
headers: _t7,
|
|
719
719
|
method: "POST",
|
|
720
|
-
path:
|
|
721
|
-
body:
|
|
720
|
+
path: _t8,
|
|
721
|
+
body: _t9,
|
|
722
722
|
allowFailover: false
|
|
723
723
|
};
|
|
724
|
-
return _context8.abrupt("return",
|
|
725
|
-
case
|
|
724
|
+
return _context8.abrupt("return", _t6.RequestJsonBody.call(_t6, _t0));
|
|
725
|
+
case 2:
|
|
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 _ref1.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
|
|
736
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref10) {
|
|
737
|
+
var libraryId, objectId, writeToken, uploadId, path, _t1, _t10, _t11, _t12, _t13, _t14;
|
|
738
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
739
739
|
while (1) switch (_context9.prev = _context9.next) {
|
|
740
740
|
case 0:
|
|
741
|
-
libraryId =
|
|
741
|
+
libraryId = _ref10.libraryId, objectId = _ref10.objectId, writeToken = _ref10.writeToken, uploadId = _ref10.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
|
+
_t1 = this.utils;
|
|
749
|
+
_t10 = this.HttpClient;
|
|
750
|
+
_context9.next = 1;
|
|
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 1:
|
|
757
|
+
_t11 = _context9.sent;
|
|
758
|
+
_t12 = path;
|
|
759
|
+
_t13 = {
|
|
760
|
+
headers: _t11,
|
|
761
761
|
method: "GET",
|
|
762
|
-
path:
|
|
762
|
+
path: _t12,
|
|
763
763
|
allowFailover: false
|
|
764
764
|
};
|
|
765
|
-
|
|
766
|
-
return _context9.abrupt("return",
|
|
767
|
-
case
|
|
765
|
+
_t14 = _t10.Request.call(_t10, _t13);
|
|
766
|
+
return _context9.abrupt("return", _t1.ResponseToJson.call(_t1, _t14));
|
|
767
|
+
case 2:
|
|
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 _ref11.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 _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref12) {
|
|
779
|
+
var libraryId, objectId, writeToken, uploadId, jobId, path, response, newResponse, _t15, _t16, _t17, _t18, _t19, _t20, _t21, _t22, _t23, _t24, _t25, _t26, _t27, _t28;
|
|
780
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
781
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
782
782
|
case 0:
|
|
783
|
-
libraryId =
|
|
783
|
+
libraryId = _ref12.libraryId, objectId = _ref12.objectId, writeToken = _ref12.writeToken, uploadId = _ref12.uploadId, jobId = _ref12.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
|
+
_t15 = this.utils;
|
|
791
|
+
_t16 = this.HttpClient;
|
|
792
|
+
_context0.next = 1;
|
|
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 1:
|
|
799
|
+
_t17 = _context0.sent;
|
|
800
|
+
_t18 = path;
|
|
801
|
+
_t19 = {
|
|
802
802
|
start: 0,
|
|
803
803
|
limit: 10000
|
|
804
804
|
};
|
|
805
|
-
|
|
806
|
-
headers:
|
|
805
|
+
_t20 = {
|
|
806
|
+
headers: _t17,
|
|
807
807
|
method: "GET",
|
|
808
|
-
path:
|
|
808
|
+
path: _t18,
|
|
809
809
|
allowFailover: false,
|
|
810
|
-
queryParams:
|
|
810
|
+
queryParams: _t19
|
|
811
811
|
};
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
return
|
|
815
|
-
case
|
|
816
|
-
response =
|
|
817
|
-
case
|
|
812
|
+
_t21 = _t16.Request.call(_t16, _t20);
|
|
813
|
+
_context0.next = 2;
|
|
814
|
+
return _t15.ResponseToJson.call(_t15, _t21);
|
|
815
|
+
case 2:
|
|
816
|
+
response = _context0.sent;
|
|
817
|
+
case 3:
|
|
818
818
|
if (!(response.next !== response.total && response.next >= 0)) {
|
|
819
|
-
|
|
819
|
+
_context0.next = 6;
|
|
820
820
|
break;
|
|
821
821
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
822
|
+
_t22 = this.utils;
|
|
823
|
+
_t23 = this.HttpClient;
|
|
824
|
+
_context0.next = 4;
|
|
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 4:
|
|
831
|
+
_t24 = _context0.sent;
|
|
832
|
+
_t25 = path;
|
|
833
|
+
_t26 = {
|
|
834
834
|
start: response.next
|
|
835
835
|
};
|
|
836
|
-
|
|
837
|
-
headers:
|
|
836
|
+
_t27 = {
|
|
837
|
+
headers: _t24,
|
|
838
838
|
method: "GET",
|
|
839
|
-
path:
|
|
839
|
+
path: _t25,
|
|
840
840
|
allowFailover: false,
|
|
841
|
-
queryParams:
|
|
841
|
+
queryParams: _t26
|
|
842
842
|
};
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
return
|
|
846
|
-
case
|
|
847
|
-
newResponse =
|
|
843
|
+
_t28 = _t23.Request.call(_t23, _t27);
|
|
844
|
+
_context0.next = 5;
|
|
845
|
+
return _t22.ResponseToJson.call(_t22, _t28);
|
|
846
|
+
case 5:
|
|
847
|
+
newResponse = _context0.sent;
|
|
848
848
|
response.files = [].concat(_toConsumableArray(response.files), _toConsumableArray(newResponse.files));
|
|
849
849
|
response.next = newResponse.next;
|
|
850
|
-
|
|
850
|
+
_context0.next = 3;
|
|
851
851
|
break;
|
|
852
|
-
case
|
|
853
|
-
return
|
|
854
|
-
case
|
|
852
|
+
case 6:
|
|
853
|
+
return _context0.abrupt("return", response);
|
|
854
|
+
case 7:
|
|
855
855
|
case "end":
|
|
856
|
-
return
|
|
856
|
+
return _context0.stop();
|
|
857
857
|
}
|
|
858
858
|
}, _callee9, this);
|
|
859
859
|
}));
|
|
860
|
-
return function (
|
|
861
|
-
return
|
|
860
|
+
return function (_x0) {
|
|
861
|
+
return _ref13.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 _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(_ref14) {
|
|
866
|
+
var libraryId, objectId, writeToken, encryption, uploadId, jobId, filePath, fileData, jobStatus, fileStatus, path, _t29, _t30, _t31, _t32, _t33, _t34, _t35, _t36, _t37, _t38;
|
|
867
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
868
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
869
869
|
case 0:
|
|
870
|
-
libraryId =
|
|
870
|
+
libraryId = _ref14.libraryId, objectId = _ref14.objectId, writeToken = _ref14.writeToken, encryption = _ref14.encryption, uploadId = _ref14.uploadId, jobId = _ref14.jobId, filePath = _ref14.filePath, fileData = _ref14.fileData;
|
|
871
871
|
ValidateParameters({
|
|
872
872
|
libraryId: libraryId,
|
|
873
873
|
objectId: objectId
|
|
874
874
|
});
|
|
875
875
|
ValidateWriteToken(writeToken);
|
|
876
|
-
|
|
876
|
+
_context1.next = 1;
|
|
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 1:
|
|
885
|
+
jobStatus = _context1.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
|
+
_context1.next = 2;
|
|
895
895
|
break;
|
|
896
896
|
}
|
|
897
|
-
return
|
|
898
|
-
case
|
|
897
|
+
return _context1.abrupt("return");
|
|
898
|
+
case 2:
|
|
899
899
|
if (fileStatus.skip) {
|
|
900
900
|
fileData = fileData.slice(fileStatus.skip);
|
|
901
901
|
}
|
|
902
|
-
case
|
|
902
|
+
case 3:
|
|
903
903
|
path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
904
|
+
_t29 = this.utils;
|
|
905
|
+
_t30 = this.HttpClient;
|
|
906
|
+
_t31 = path;
|
|
907
|
+
_t32 = fileData;
|
|
908
|
+
_t33 = _objectSpread;
|
|
909
|
+
_t34 = {
|
|
910
910
|
"Content-type": "application/octet-stream"
|
|
911
911
|
};
|
|
912
|
-
|
|
912
|
+
_context1.next = 4;
|
|
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 4:
|
|
919
|
+
_t35 = _context1.sent;
|
|
920
|
+
_t36 = _t33(_t34, _t35);
|
|
921
|
+
_t37 = {
|
|
922
922
|
method: "POST",
|
|
923
|
-
path:
|
|
924
|
-
body:
|
|
923
|
+
path: _t31,
|
|
924
|
+
body: _t32,
|
|
925
925
|
bodyType: "BINARY",
|
|
926
|
-
headers:
|
|
926
|
+
headers: _t36,
|
|
927
927
|
allowFailover: false,
|
|
928
928
|
allowRetry: false
|
|
929
929
|
};
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
return
|
|
933
|
-
case
|
|
934
|
-
return
|
|
935
|
-
case
|
|
930
|
+
_t38 = _t30.Request.call(_t30, _t37);
|
|
931
|
+
_context1.next = 5;
|
|
932
|
+
return _t29.ResponseToJson.call(_t29, _t38);
|
|
933
|
+
case 5:
|
|
934
|
+
return _context1.abrupt("return", _context1.sent);
|
|
935
|
+
case 6:
|
|
936
936
|
case "end":
|
|
937
|
-
return
|
|
937
|
+
return _context1.stop();
|
|
938
938
|
}
|
|
939
|
-
},
|
|
939
|
+
}, _callee0, this);
|
|
940
940
|
}));
|
|
941
|
-
return function (
|
|
942
|
-
return
|
|
941
|
+
return function (_x1) {
|
|
942
|
+
return _ref15.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 _ref17 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(_ref16) {
|
|
947
|
+
var libraryId, objectId, writeToken, path, _t39, _t40, _t41, _t42;
|
|
948
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
949
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
950
950
|
case 0:
|
|
951
|
-
libraryId =
|
|
951
|
+
libraryId = _ref16.libraryId, objectId = _ref16.objectId, writeToken = _ref16.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
|
+
_t39 = this.HttpClient;
|
|
960
|
+
_t40 = path;
|
|
961
|
+
_context10.next = 1;
|
|
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 1:
|
|
968
|
+
_t41 = _context10.sent;
|
|
969
|
+
_t42 = {
|
|
970
970
|
method: "POST",
|
|
971
|
-
path:
|
|
971
|
+
path: _t40,
|
|
972
972
|
bodyType: "BINARY",
|
|
973
|
-
headers:
|
|
973
|
+
headers: _t41,
|
|
974
974
|
allowFailover: false
|
|
975
975
|
};
|
|
976
|
-
|
|
977
|
-
return
|
|
978
|
-
case
|
|
976
|
+
_context10.next = 2;
|
|
977
|
+
return _t39.Request.call(_t39, _t42);
|
|
978
|
+
case 2:
|
|
979
979
|
case "end":
|
|
980
|
-
return
|
|
980
|
+
return _context10.stop();
|
|
981
981
|
}
|
|
982
|
-
},
|
|
982
|
+
}, _callee1, this);
|
|
983
983
|
}));
|
|
984
|
-
return function (
|
|
985
|
-
return
|
|
984
|
+
return function (_x10) {
|
|
985
|
+
return _ref17.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 _ref19 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref18) {
|
|
1002
1002
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1003
|
-
return _regeneratorRuntime.wrap(function
|
|
1004
|
-
while (1) switch (
|
|
1003
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
1004
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1005
1005
|
case 0:
|
|
1006
|
-
libraryId =
|
|
1006
|
+
libraryId = _ref18.libraryId, objectId = _ref18.objectId, writeToken = _ref18.writeToken, filePaths = _ref18.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
|
+
_context11.next = 1;
|
|
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 1:
|
|
1029
1029
|
case "end":
|
|
1030
|
-
return
|
|
1030
|
+
return _context11.stop();
|
|
1031
1031
|
}
|
|
1032
|
-
},
|
|
1032
|
+
}, _callee10, this);
|
|
1033
1033
|
}));
|
|
1034
|
-
return function (
|
|
1035
|
-
return
|
|
1034
|
+
return function (_x11) {
|
|
1035
|
+
return _ref19.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 _ref21 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref20) {
|
|
1052
1052
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1053
|
-
return _regeneratorRuntime.wrap(function
|
|
1054
|
-
while (1) switch (
|
|
1053
|
+
return _regeneratorRuntime.wrap(function (_context12) {
|
|
1054
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1055
1055
|
case 0:
|
|
1056
|
-
libraryId =
|
|
1056
|
+
libraryId = _ref20.libraryId, objectId = _ref20.objectId, writeToken = _ref20.writeToken, filePaths = _ref20.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 (_ref22) {
|
|
1065
|
+
var path = _ref22.path,
|
|
1066
|
+
to = _ref22.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
|
+
_context12.next = 1;
|
|
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 1:
|
|
1081
1081
|
case "end":
|
|
1082
|
-
return
|
|
1082
|
+
return _context12.stop();
|
|
1083
1083
|
}
|
|
1084
|
-
},
|
|
1084
|
+
}, _callee11, this);
|
|
1085
1085
|
}));
|
|
1086
|
-
return function (
|
|
1087
|
-
return
|
|
1086
|
+
return function (_x12) {
|
|
1087
|
+
return _ref21.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 _ref24 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref23) {
|
|
1104
1104
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1105
|
-
return _regeneratorRuntime.wrap(function
|
|
1106
|
-
while (1) switch (
|
|
1105
|
+
return _regeneratorRuntime.wrap(function (_context13) {
|
|
1106
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1107
1107
|
case 0:
|
|
1108
|
-
libraryId =
|
|
1108
|
+
libraryId = _ref23.libraryId, objectId = _ref23.objectId, writeToken = _ref23.writeToken, filePaths = _ref23.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
|
+
_context13.next = 1;
|
|
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 1:
|
|
1130
1130
|
case "end":
|
|
1131
|
-
return
|
|
1131
|
+
return _context13.stop();
|
|
1132
1132
|
}
|
|
1133
|
-
},
|
|
1133
|
+
}, _callee12, this);
|
|
1134
1134
|
}));
|
|
1135
|
-
return function (
|
|
1136
|
-
return
|
|
1135
|
+
return function (_x13) {
|
|
1136
|
+
return _ref24.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 _ref26 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref25) {
|
|
1166
1166
|
var libraryId,
|
|
1167
1167
|
objectId,
|
|
1168
1168
|
versionHash,
|
|
1169
1169
|
writeToken,
|
|
1170
1170
|
filePath,
|
|
1171
|
-
|
|
1171
|
+
_ref25$format,
|
|
1172
1172
|
format,
|
|
1173
|
-
|
|
1173
|
+
_ref25$chunked,
|
|
1174
1174
|
chunked,
|
|
1175
1175
|
chunkSize,
|
|
1176
|
-
|
|
1176
|
+
_ref25$clientSideDecr,
|
|
1177
1177
|
clientSideDecryption,
|
|
1178
1178
|
callback,
|
|
1179
1179
|
fileInfo,
|
|
@@ -1184,11 +1184,27 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1184
1184
|
ownerCapKey,
|
|
1185
1185
|
ownerCap,
|
|
1186
1186
|
bytesTotal,
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1187
|
+
_args14 = arguments,
|
|
1188
|
+
_t43,
|
|
1189
|
+
_t44,
|
|
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) {
|
|
1190
1206
|
case 0:
|
|
1191
|
-
libraryId =
|
|
1207
|
+
libraryId = _ref25.libraryId, objectId = _ref25.objectId, versionHash = _ref25.versionHash, writeToken = _ref25.writeToken, filePath = _ref25.filePath, _ref25$format = _ref25.format, format = _ref25$format === void 0 ? "arrayBuffer" : _ref25$format, _ref25$chunked = _ref25.chunked, chunked = _ref25$chunked === void 0 ? false : _ref25$chunked, chunkSize = _ref25.chunkSize, _ref25$clientSideDecr = _ref25.clientSideDecryption, clientSideDecryption = _ref25$clientSideDecr === void 0 ? false : _ref25$clientSideDecr, callback = _ref25.callback;
|
|
1192
1208
|
ValidateParameters({
|
|
1193
1209
|
libraryId: libraryId,
|
|
1194
1210
|
objectId: objectId,
|
|
@@ -1198,7 +1214,7 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1198
1214
|
if (versionHash) {
|
|
1199
1215
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1200
1216
|
}
|
|
1201
|
-
|
|
1217
|
+
_context14.next = 1;
|
|
1202
1218
|
return this.ContentObjectMetadata({
|
|
1203
1219
|
libraryId: libraryId,
|
|
1204
1220
|
objectId: objectId,
|
|
@@ -1206,12 +1222,12 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1206
1222
|
writeToken: writeToken,
|
|
1207
1223
|
metadataSubtree: UrlJoin("files", filePath)
|
|
1208
1224
|
});
|
|
1209
|
-
case
|
|
1210
|
-
fileInfo =
|
|
1225
|
+
case 1:
|
|
1226
|
+
fileInfo = _context14.sent;
|
|
1211
1227
|
encrypted = fileInfo && fileInfo["."].encryption && fileInfo["."].encryption.scheme === "cgck";
|
|
1212
1228
|
encryption = encrypted ? "cgck" : undefined;
|
|
1213
1229
|
path = encrypted && !clientSideDecryption ? UrlJoin("q", writeToken || versionHash || objectId, "rep", "files_download", filePath) : UrlJoin("q", writeToken || versionHash || objectId, "files", filePath);
|
|
1214
|
-
|
|
1230
|
+
_context14.next = 2;
|
|
1215
1231
|
return this.authClient.AuthorizationHeader({
|
|
1216
1232
|
libraryId: libraryId,
|
|
1217
1233
|
objectId: objectId,
|
|
@@ -1219,49 +1235,49 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1219
1235
|
encryption: encryption,
|
|
1220
1236
|
makeAccessRequest: encryption === "cgck"
|
|
1221
1237
|
});
|
|
1222
|
-
case
|
|
1223
|
-
headers =
|
|
1238
|
+
case 2:
|
|
1239
|
+
headers = _context14.sent;
|
|
1224
1240
|
headers.Accept = "*/*";
|
|
1225
1241
|
|
|
1226
1242
|
// If not owner, indicate re-encryption
|
|
1227
1243
|
ownerCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
|
|
1228
|
-
|
|
1244
|
+
_context14.next = 3;
|
|
1229
1245
|
return this.ContentObjectMetadata({
|
|
1230
1246
|
libraryId: libraryId,
|
|
1231
1247
|
objectId: objectId,
|
|
1232
1248
|
versionHash: versionHash,
|
|
1233
1249
|
metadataSubtree: ownerCapKey
|
|
1234
1250
|
});
|
|
1235
|
-
case
|
|
1236
|
-
ownerCap =
|
|
1237
|
-
|
|
1238
|
-
if (!
|
|
1239
|
-
|
|
1251
|
+
case 3:
|
|
1252
|
+
ownerCap = _context14.sent;
|
|
1253
|
+
_t44 = encrypted;
|
|
1254
|
+
if (!_t44) {
|
|
1255
|
+
_context14.next = 5;
|
|
1240
1256
|
break;
|
|
1241
1257
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1258
|
+
_t45 = this.utils;
|
|
1259
|
+
_t46 = this.signer.address;
|
|
1260
|
+
_context14.next = 4;
|
|
1245
1261
|
return this.ContentObjectOwner({
|
|
1246
1262
|
objectId: objectId
|
|
1247
1263
|
});
|
|
1248
|
-
case
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
case
|
|
1252
|
-
|
|
1253
|
-
if (!
|
|
1254
|
-
|
|
1264
|
+
case 4:
|
|
1265
|
+
_t47 = _context14.sent;
|
|
1266
|
+
_t44 = !_t45.EqualAddress.call(_t45, _t46, _t47);
|
|
1267
|
+
case 5:
|
|
1268
|
+
_t43 = _t44;
|
|
1269
|
+
if (!_t43) {
|
|
1270
|
+
_context14.next = 6;
|
|
1255
1271
|
break;
|
|
1256
1272
|
}
|
|
1257
|
-
|
|
1258
|
-
case
|
|
1259
|
-
if (!
|
|
1260
|
-
|
|
1273
|
+
_t43 = !ownerCap;
|
|
1274
|
+
case 6:
|
|
1275
|
+
if (!_t43) {
|
|
1276
|
+
_context14.next = 7;
|
|
1261
1277
|
break;
|
|
1262
1278
|
}
|
|
1263
1279
|
headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
|
|
1264
|
-
case
|
|
1280
|
+
case 7:
|
|
1265
1281
|
// If using server side decryption, specify in header
|
|
1266
1282
|
if (encrypted && !clientSideDecryption) {
|
|
1267
1283
|
headers["X-Content-Fabric-Decryption-Mode"] = "decrypt";
|
|
@@ -1270,46 +1286,46 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1270
1286
|
}
|
|
1271
1287
|
bytesTotal = fileInfo["."].size;
|
|
1272
1288
|
if (!(encrypted && clientSideDecryption)) {
|
|
1273
|
-
|
|
1289
|
+
_context14.next = 10;
|
|
1274
1290
|
break;
|
|
1275
1291
|
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1292
|
+
_t48 = this;
|
|
1293
|
+
_context14.next = 8;
|
|
1278
1294
|
return this.EncryptionConk({
|
|
1279
1295
|
libraryId: libraryId,
|
|
1280
1296
|
objectId: objectId,
|
|
1281
1297
|
versionHash: versionHash,
|
|
1282
1298
|
download: true
|
|
1283
1299
|
});
|
|
1284
|
-
case
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
conk:
|
|
1295
|
-
downloadPath:
|
|
1296
|
-
bytesTotal:
|
|
1297
|
-
headers:
|
|
1298
|
-
callback:
|
|
1299
|
-
format:
|
|
1300
|
-
clientSideDecryption:
|
|
1301
|
-
chunked:
|
|
1300
|
+
case 8:
|
|
1301
|
+
_t49 = _context14.sent;
|
|
1302
|
+
_t50 = path;
|
|
1303
|
+
_t51 = bytesTotal;
|
|
1304
|
+
_t52 = headers;
|
|
1305
|
+
_t53 = callback;
|
|
1306
|
+
_t54 = format;
|
|
1307
|
+
_t55 = clientSideDecryption;
|
|
1308
|
+
_t56 = chunked;
|
|
1309
|
+
_t57 = {
|
|
1310
|
+
conk: _t49,
|
|
1311
|
+
downloadPath: _t50,
|
|
1312
|
+
bytesTotal: _t51,
|
|
1313
|
+
headers: _t52,
|
|
1314
|
+
callback: _t53,
|
|
1315
|
+
format: _t54,
|
|
1316
|
+
clientSideDecryption: _t55,
|
|
1317
|
+
chunked: _t56
|
|
1302
1318
|
};
|
|
1303
|
-
|
|
1304
|
-
return
|
|
1305
|
-
case
|
|
1306
|
-
return
|
|
1307
|
-
case
|
|
1319
|
+
_context14.next = 9;
|
|
1320
|
+
return _t48.DownloadEncrypted.call(_t48, _t57);
|
|
1321
|
+
case 9:
|
|
1322
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1323
|
+
case 10:
|
|
1308
1324
|
if (!chunkSize) {
|
|
1309
1325
|
chunkSize = 10000000;
|
|
1310
1326
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1327
|
+
_context14.prev = 11;
|
|
1328
|
+
_context14.next = 12;
|
|
1313
1329
|
return this.Download({
|
|
1314
1330
|
downloadPath: path,
|
|
1315
1331
|
bytesTotal: bytesTotal,
|
|
@@ -1319,28 +1335,28 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1319
1335
|
chunked: chunked,
|
|
1320
1336
|
chunkSize: chunkSize
|
|
1321
1337
|
});
|
|
1322
|
-
case
|
|
1323
|
-
return
|
|
1324
|
-
case
|
|
1325
|
-
|
|
1326
|
-
|
|
1338
|
+
case 12:
|
|
1339
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1340
|
+
case 13:
|
|
1341
|
+
_context14.prev = 13;
|
|
1342
|
+
_t58 = _context14["catch"](11);
|
|
1327
1343
|
if (!(encrypted && !clientSideDecryption)) {
|
|
1328
|
-
|
|
1344
|
+
_context14.next = 14;
|
|
1329
1345
|
break;
|
|
1330
1346
|
}
|
|
1331
|
-
return
|
|
1347
|
+
return _context14.abrupt("return", this.DownloadFile(_objectSpread(_objectSpread({}, _args14[0]), {}, {
|
|
1332
1348
|
clientSideDecryption: true
|
|
1333
1349
|
})));
|
|
1334
|
-
case
|
|
1335
|
-
throw
|
|
1336
|
-
case
|
|
1350
|
+
case 14:
|
|
1351
|
+
throw _t58;
|
|
1352
|
+
case 15:
|
|
1337
1353
|
case "end":
|
|
1338
|
-
return
|
|
1354
|
+
return _context14.stop();
|
|
1339
1355
|
}
|
|
1340
|
-
},
|
|
1356
|
+
}, _callee13, this, [[11, 13]]);
|
|
1341
1357
|
}));
|
|
1342
|
-
return function (
|
|
1343
|
-
return
|
|
1358
|
+
return function (_x14) {
|
|
1359
|
+
return _ref26.apply(this, arguments);
|
|
1344
1360
|
};
|
|
1345
1361
|
}();
|
|
1346
1362
|
|
|
@@ -1359,12 +1375,12 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1359
1375
|
* @returns {Promise<Object>} - Response containing list of parts of the object
|
|
1360
1376
|
*/
|
|
1361
1377
|
exports.ContentParts = /*#__PURE__*/function () {
|
|
1362
|
-
var
|
|
1363
|
-
var libraryId, objectId, versionHash, path, response;
|
|
1364
|
-
return _regeneratorRuntime.wrap(function
|
|
1365
|
-
while (1) switch (
|
|
1378
|
+
var _ref28 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref27) {
|
|
1379
|
+
var libraryId, objectId, versionHash, path, response, _t59, _t60, _t61, _t62;
|
|
1380
|
+
return _regeneratorRuntime.wrap(function (_context15) {
|
|
1381
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1366
1382
|
case 0:
|
|
1367
|
-
libraryId =
|
|
1383
|
+
libraryId = _ref27.libraryId, objectId = _ref27.objectId, versionHash = _ref27.versionHash;
|
|
1368
1384
|
ValidateParameters({
|
|
1369
1385
|
libraryId: libraryId,
|
|
1370
1386
|
objectId: objectId,
|
|
@@ -1375,34 +1391,34 @@ exports.ContentParts = /*#__PURE__*/function () {
|
|
|
1375
1391
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1376
1392
|
}
|
|
1377
1393
|
path = UrlJoin("q", versionHash || objectId, "parts");
|
|
1378
|
-
|
|
1379
|
-
|
|
1394
|
+
_t59 = this.HttpClient;
|
|
1395
|
+
_context15.next = 1;
|
|
1380
1396
|
return this.authClient.AuthorizationHeader({
|
|
1381
1397
|
libraryId: libraryId,
|
|
1382
1398
|
objectId: objectId,
|
|
1383
1399
|
versionHash: versionHash
|
|
1384
1400
|
});
|
|
1385
|
-
case
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
headers:
|
|
1401
|
+
case 1:
|
|
1402
|
+
_t60 = _context15.sent;
|
|
1403
|
+
_t61 = path;
|
|
1404
|
+
_t62 = {
|
|
1405
|
+
headers: _t60,
|
|
1390
1406
|
method: "GET",
|
|
1391
|
-
path:
|
|
1407
|
+
path: _t61
|
|
1392
1408
|
};
|
|
1393
|
-
|
|
1394
|
-
return
|
|
1395
|
-
case
|
|
1396
|
-
response =
|
|
1397
|
-
return
|
|
1398
|
-
case
|
|
1409
|
+
_context15.next = 2;
|
|
1410
|
+
return _t59.RequestJsonBody.call(_t59, _t62);
|
|
1411
|
+
case 2:
|
|
1412
|
+
response = _context15.sent;
|
|
1413
|
+
return _context15.abrupt("return", response.parts);
|
|
1414
|
+
case 3:
|
|
1399
1415
|
case "end":
|
|
1400
|
-
return
|
|
1416
|
+
return _context15.stop();
|
|
1401
1417
|
}
|
|
1402
|
-
},
|
|
1418
|
+
}, _callee14, this);
|
|
1403
1419
|
}));
|
|
1404
|
-
return function (
|
|
1405
|
-
return
|
|
1420
|
+
return function (_x15) {
|
|
1421
|
+
return _ref28.apply(this, arguments);
|
|
1406
1422
|
};
|
|
1407
1423
|
}();
|
|
1408
1424
|
|
|
@@ -1420,12 +1436,12 @@ exports.ContentParts = /*#__PURE__*/function () {
|
|
|
1420
1436
|
* @returns {Promise<Object>} - Response containing information about the specified part
|
|
1421
1437
|
*/
|
|
1422
1438
|
exports.ContentPart = /*#__PURE__*/function () {
|
|
1423
|
-
var
|
|
1424
|
-
var libraryId, objectId, versionHash, partHash, path;
|
|
1425
|
-
return _regeneratorRuntime.wrap(function
|
|
1426
|
-
while (1) switch (
|
|
1439
|
+
var _ref30 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref29) {
|
|
1440
|
+
var libraryId, objectId, versionHash, partHash, path, _t63, _t64, _t65, _t66;
|
|
1441
|
+
return _regeneratorRuntime.wrap(function (_context16) {
|
|
1442
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1427
1443
|
case 0:
|
|
1428
|
-
libraryId =
|
|
1444
|
+
libraryId = _ref29.libraryId, objectId = _ref29.objectId, versionHash = _ref29.versionHash, partHash = _ref29.partHash;
|
|
1429
1445
|
ValidateParameters({
|
|
1430
1446
|
libraryId: libraryId,
|
|
1431
1447
|
objectId: objectId,
|
|
@@ -1437,33 +1453,33 @@ exports.ContentPart = /*#__PURE__*/function () {
|
|
|
1437
1453
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1438
1454
|
}
|
|
1439
1455
|
path = UrlJoin("q", versionHash || objectId, "parts", partHash);
|
|
1440
|
-
|
|
1441
|
-
|
|
1456
|
+
_t63 = this.HttpClient;
|
|
1457
|
+
_context16.next = 1;
|
|
1442
1458
|
return this.authClient.AuthorizationHeader({
|
|
1443
1459
|
libraryId: libraryId,
|
|
1444
1460
|
objectId: objectId,
|
|
1445
1461
|
versionHash: versionHash
|
|
1446
1462
|
});
|
|
1447
|
-
case
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
headers:
|
|
1463
|
+
case 1:
|
|
1464
|
+
_t64 = _context16.sent;
|
|
1465
|
+
_t65 = path;
|
|
1466
|
+
_t66 = {
|
|
1467
|
+
headers: _t64,
|
|
1452
1468
|
method: "GET",
|
|
1453
|
-
path:
|
|
1469
|
+
path: _t65
|
|
1454
1470
|
};
|
|
1455
|
-
|
|
1456
|
-
return
|
|
1457
|
-
case
|
|
1458
|
-
return
|
|
1459
|
-
case
|
|
1471
|
+
_context16.next = 2;
|
|
1472
|
+
return _t63.RequestJsonBody.call(_t63, _t66);
|
|
1473
|
+
case 2:
|
|
1474
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1475
|
+
case 3:
|
|
1460
1476
|
case "end":
|
|
1461
|
-
return
|
|
1477
|
+
return _context16.stop();
|
|
1462
1478
|
}
|
|
1463
|
-
},
|
|
1479
|
+
}, _callee15, this);
|
|
1464
1480
|
}));
|
|
1465
|
-
return function (
|
|
1466
|
-
return
|
|
1481
|
+
return function (_x16) {
|
|
1482
|
+
return _ref30.apply(this, arguments);
|
|
1467
1483
|
};
|
|
1468
1484
|
}();
|
|
1469
1485
|
|
|
@@ -1492,12 +1508,12 @@ exports.ContentPart = /*#__PURE__*/function () {
|
|
|
1492
1508
|
* @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, part data in the requested format otherwise
|
|
1493
1509
|
*/
|
|
1494
1510
|
exports.DownloadPart = /*#__PURE__*/function () {
|
|
1495
|
-
var
|
|
1496
|
-
var libraryId, objectId, versionHash, writeToken, partHash,
|
|
1497
|
-
return _regeneratorRuntime.wrap(function
|
|
1498
|
-
while (1) switch (
|
|
1511
|
+
var _ref32 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref31) {
|
|
1512
|
+
var libraryId, objectId, versionHash, writeToken, partHash, _ref31$format, format, _ref31$chunked, chunked, _ref31$chunkSize, chunkSize, callback, encrypted, encryption, path, headers, bytesTotal, _t67, _t68, _t69, _t70, _t71, _t72, _t73, _t74, _t75, _t76, _t77, _t78;
|
|
1513
|
+
return _regeneratorRuntime.wrap(function (_context17) {
|
|
1514
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1499
1515
|
case 0:
|
|
1500
|
-
libraryId =
|
|
1516
|
+
libraryId = _ref31.libraryId, objectId = _ref31.objectId, versionHash = _ref31.versionHash, writeToken = _ref31.writeToken, partHash = _ref31.partHash, _ref31$format = _ref31.format, format = _ref31$format === void 0 ? "arrayBuffer" : _ref31$format, _ref31$chunked = _ref31.chunked, chunked = _ref31$chunked === void 0 ? false : _ref31$chunked, _ref31$chunkSize = _ref31.chunkSize, chunkSize = _ref31$chunkSize === void 0 ? 10000000 : _ref31$chunkSize, callback = _ref31.callback;
|
|
1501
1517
|
ValidateParameters({
|
|
1502
1518
|
libraryId: libraryId,
|
|
1503
1519
|
objectId: objectId,
|
|
@@ -1510,7 +1526,7 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
1510
1526
|
encrypted = partHash.startsWith("hqpe");
|
|
1511
1527
|
encryption = encrypted ? "cgck" : undefined;
|
|
1512
1528
|
path = UrlJoin("q", writeToken || versionHash || objectId, "data", partHash);
|
|
1513
|
-
|
|
1529
|
+
_context17.next = 1;
|
|
1514
1530
|
return this.authClient.AuthorizationHeader({
|
|
1515
1531
|
libraryId: libraryId,
|
|
1516
1532
|
objectId: objectId,
|
|
@@ -1518,65 +1534,65 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
1518
1534
|
encryption: encryption,
|
|
1519
1535
|
makeAccessRequest: true
|
|
1520
1536
|
});
|
|
1521
|
-
case
|
|
1522
|
-
headers =
|
|
1523
|
-
|
|
1537
|
+
case 1:
|
|
1538
|
+
headers = _context17.sent;
|
|
1539
|
+
_context17.next = 2;
|
|
1524
1540
|
return this.ContentPart({
|
|
1525
1541
|
libraryId: libraryId,
|
|
1526
1542
|
objectId: objectId,
|
|
1527
1543
|
versionHash: versionHash,
|
|
1528
1544
|
partHash: partHash
|
|
1529
1545
|
});
|
|
1530
|
-
case
|
|
1531
|
-
bytesTotal =
|
|
1546
|
+
case 2:
|
|
1547
|
+
bytesTotal = _context17.sent.part.size;
|
|
1532
1548
|
if (!encrypted) {
|
|
1533
|
-
|
|
1549
|
+
_context17.next = 7;
|
|
1534
1550
|
break;
|
|
1535
1551
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1552
|
+
_t67 = this.utils;
|
|
1553
|
+
_t68 = this.signer.address;
|
|
1554
|
+
_context17.next = 3;
|
|
1539
1555
|
return this.ContentObjectOwner({
|
|
1540
1556
|
objectId: objectId
|
|
1541
1557
|
});
|
|
1542
|
-
case
|
|
1543
|
-
|
|
1544
|
-
if (
|
|
1545
|
-
|
|
1558
|
+
case 3:
|
|
1559
|
+
_t69 = _context17.sent;
|
|
1560
|
+
if (_t67.EqualAddress.call(_t67, _t68, _t69)) {
|
|
1561
|
+
_context17.next = 4;
|
|
1546
1562
|
break;
|
|
1547
1563
|
}
|
|
1548
1564
|
headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
|
|
1549
|
-
case
|
|
1550
|
-
|
|
1551
|
-
|
|
1565
|
+
case 4:
|
|
1566
|
+
_t70 = this;
|
|
1567
|
+
_context17.next = 5;
|
|
1552
1568
|
return this.EncryptionConk({
|
|
1553
1569
|
libraryId: libraryId,
|
|
1554
1570
|
objectId: objectId,
|
|
1555
1571
|
download: true
|
|
1556
1572
|
});
|
|
1557
|
-
case
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
conk:
|
|
1567
|
-
downloadPath:
|
|
1568
|
-
bytesTotal:
|
|
1569
|
-
headers:
|
|
1570
|
-
callback:
|
|
1571
|
-
format:
|
|
1572
|
-
chunked:
|
|
1573
|
+
case 5:
|
|
1574
|
+
_t71 = _context17.sent;
|
|
1575
|
+
_t72 = path;
|
|
1576
|
+
_t73 = bytesTotal;
|
|
1577
|
+
_t74 = headers;
|
|
1578
|
+
_t75 = callback;
|
|
1579
|
+
_t76 = format;
|
|
1580
|
+
_t77 = chunked;
|
|
1581
|
+
_t78 = {
|
|
1582
|
+
conk: _t71,
|
|
1583
|
+
downloadPath: _t72,
|
|
1584
|
+
bytesTotal: _t73,
|
|
1585
|
+
headers: _t74,
|
|
1586
|
+
callback: _t75,
|
|
1587
|
+
format: _t76,
|
|
1588
|
+
chunked: _t77
|
|
1573
1589
|
};
|
|
1574
|
-
|
|
1575
|
-
return
|
|
1576
|
-
case
|
|
1577
|
-
return
|
|
1578
|
-
case
|
|
1579
|
-
|
|
1590
|
+
_context17.next = 6;
|
|
1591
|
+
return _t70.DownloadEncrypted.call(_t70, _t78);
|
|
1592
|
+
case 6:
|
|
1593
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1594
|
+
case 7:
|
|
1595
|
+
_context17.next = 8;
|
|
1580
1596
|
return this.Download({
|
|
1581
1597
|
downloadPath: path,
|
|
1582
1598
|
bytesTotal: bytesTotal,
|
|
@@ -1586,31 +1602,31 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
1586
1602
|
chunked: chunked,
|
|
1587
1603
|
chunkSize: chunkSize
|
|
1588
1604
|
});
|
|
1589
|
-
case
|
|
1590
|
-
return
|
|
1591
|
-
case
|
|
1605
|
+
case 8:
|
|
1606
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1607
|
+
case 9:
|
|
1592
1608
|
case "end":
|
|
1593
|
-
return
|
|
1609
|
+
return _context17.stop();
|
|
1594
1610
|
}
|
|
1595
|
-
},
|
|
1611
|
+
}, _callee16, this);
|
|
1596
1612
|
}));
|
|
1597
|
-
return function (
|
|
1598
|
-
return
|
|
1613
|
+
return function (_x17) {
|
|
1614
|
+
return _ref32.apply(this, arguments);
|
|
1599
1615
|
};
|
|
1600
1616
|
}();
|
|
1601
1617
|
exports.Download = /*#__PURE__*/function () {
|
|
1602
|
-
var
|
|
1603
|
-
var downloadPath, headers, bytesTotal,
|
|
1604
|
-
return _regeneratorRuntime.wrap(function
|
|
1605
|
-
while (1) switch (
|
|
1618
|
+
var _ref34 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref33) {
|
|
1619
|
+
var downloadPath, headers, bytesTotal, _ref33$chunked, chunked, _ref33$chunkSize, chunkSize, callback, _ref33$format, format, outputChunks, bytesFinished, totalChunks, i, response, _t79, _t80, _t81, _t82, _t83, _t84, _t85, _t86, _t87;
|
|
1620
|
+
return _regeneratorRuntime.wrap(function (_context18) {
|
|
1621
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1606
1622
|
case 0:
|
|
1607
|
-
downloadPath =
|
|
1623
|
+
downloadPath = _ref33.downloadPath, headers = _ref33.headers, bytesTotal = _ref33.bytesTotal, _ref33$chunked = _ref33.chunked, chunked = _ref33$chunked === void 0 ? false : _ref33$chunked, _ref33$chunkSize = _ref33.chunkSize, chunkSize = _ref33$chunkSize === void 0 ? 2000000 : _ref33$chunkSize, callback = _ref33.callback, _ref33$format = _ref33.format, format = _ref33$format === void 0 ? "arrayBuffer" : _ref33$format;
|
|
1608
1624
|
if (!(chunked && !callback)) {
|
|
1609
|
-
|
|
1625
|
+
_context18.next = 1;
|
|
1610
1626
|
break;
|
|
1611
1627
|
}
|
|
1612
1628
|
throw Error("No callback specified for chunked download");
|
|
1613
|
-
case
|
|
1629
|
+
case 1:
|
|
1614
1630
|
if (!chunked) {
|
|
1615
1631
|
outputChunks = [];
|
|
1616
1632
|
}
|
|
@@ -1619,138 +1635,138 @@ exports.Download = /*#__PURE__*/function () {
|
|
|
1619
1635
|
bytesFinished = 0;
|
|
1620
1636
|
totalChunks = Math.ceil(bytesTotal / chunkSize);
|
|
1621
1637
|
i = 0;
|
|
1622
|
-
case
|
|
1638
|
+
case 2:
|
|
1623
1639
|
if (!(i < totalChunks)) {
|
|
1624
|
-
|
|
1640
|
+
_context18.next = 8;
|
|
1625
1641
|
break;
|
|
1626
1642
|
}
|
|
1627
1643
|
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
1628
|
-
|
|
1644
|
+
_context18.next = 3;
|
|
1629
1645
|
return this.HttpClient.Request({
|
|
1630
1646
|
path: downloadPath,
|
|
1631
1647
|
headers: headers,
|
|
1632
1648
|
method: "GET"
|
|
1633
1649
|
});
|
|
1634
|
-
case
|
|
1635
|
-
response =
|
|
1650
|
+
case 3:
|
|
1651
|
+
response = _context18.sent;
|
|
1636
1652
|
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
1637
1653
|
if (!chunked) {
|
|
1638
|
-
|
|
1654
|
+
_context18.next = 5;
|
|
1639
1655
|
break;
|
|
1640
1656
|
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1657
|
+
_t79 = callback;
|
|
1658
|
+
_t80 = bytesFinished;
|
|
1659
|
+
_t81 = bytesTotal;
|
|
1660
|
+
_context18.next = 4;
|
|
1645
1661
|
return this.utils.ResponseToFormat(format, response);
|
|
1646
|
-
case
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
bytesFinished:
|
|
1650
|
-
bytesTotal:
|
|
1651
|
-
chunk:
|
|
1662
|
+
case 4:
|
|
1663
|
+
_t82 = _context18.sent;
|
|
1664
|
+
_t83 = {
|
|
1665
|
+
bytesFinished: _t80,
|
|
1666
|
+
bytesTotal: _t81,
|
|
1667
|
+
chunk: _t82
|
|
1652
1668
|
};
|
|
1653
|
-
(
|
|
1654
|
-
|
|
1669
|
+
_t79(_t83);
|
|
1670
|
+
_context18.next = 7;
|
|
1655
1671
|
break;
|
|
1656
|
-
case
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1672
|
+
case 5:
|
|
1673
|
+
_t84 = outputChunks;
|
|
1674
|
+
_t85 = Buffer;
|
|
1675
|
+
_context18.next = 6;
|
|
1660
1676
|
return response.arrayBuffer();
|
|
1661
|
-
case
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1677
|
+
case 6:
|
|
1678
|
+
_t86 = _context18.sent;
|
|
1679
|
+
_t87 = _t85.from.call(_t85, _t86);
|
|
1680
|
+
_t84.push.call(_t84, _t87);
|
|
1665
1681
|
if (callback) {
|
|
1666
1682
|
callback({
|
|
1667
1683
|
bytesFinished: bytesFinished,
|
|
1668
1684
|
bytesTotal: bytesTotal
|
|
1669
1685
|
});
|
|
1670
1686
|
}
|
|
1671
|
-
case
|
|
1687
|
+
case 7:
|
|
1672
1688
|
i++;
|
|
1673
|
-
|
|
1689
|
+
_context18.next = 2;
|
|
1674
1690
|
break;
|
|
1675
|
-
case
|
|
1691
|
+
case 8:
|
|
1676
1692
|
if (chunked) {
|
|
1677
|
-
|
|
1693
|
+
_context18.next = 10;
|
|
1678
1694
|
break;
|
|
1679
1695
|
}
|
|
1680
|
-
|
|
1696
|
+
_context18.next = 9;
|
|
1681
1697
|
return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
|
|
1682
|
-
case
|
|
1683
|
-
return
|
|
1684
|
-
case
|
|
1698
|
+
case 9:
|
|
1699
|
+
return _context18.abrupt("return", _context18.sent);
|
|
1700
|
+
case 10:
|
|
1685
1701
|
case "end":
|
|
1686
|
-
return
|
|
1702
|
+
return _context18.stop();
|
|
1687
1703
|
}
|
|
1688
|
-
},
|
|
1704
|
+
}, _callee17, this);
|
|
1689
1705
|
}));
|
|
1690
|
-
return function (
|
|
1691
|
-
return
|
|
1706
|
+
return function (_x18) {
|
|
1707
|
+
return _ref34.apply(this, arguments);
|
|
1692
1708
|
};
|
|
1693
1709
|
}();
|
|
1694
1710
|
exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
1695
|
-
var
|
|
1711
|
+
var _ref36 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref35) {
|
|
1696
1712
|
var _this2 = this;
|
|
1697
|
-
var conk, downloadPath, bytesTotal, headers, callback,
|
|
1698
|
-
return _regeneratorRuntime.wrap(function
|
|
1699
|
-
while (1) switch (
|
|
1713
|
+
var conk, downloadPath, bytesTotal, headers, callback, _ref35$format, format, _ref35$chunked, chunked, isReencryption, chunkSize, bytesFinished, outputChunks, stream, totalChunks, i, response, _t88, _t89, _t90, _t91;
|
|
1714
|
+
return _regeneratorRuntime.wrap(function (_context20) {
|
|
1715
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1700
1716
|
case 0:
|
|
1701
|
-
conk =
|
|
1717
|
+
conk = _ref35.conk, downloadPath = _ref35.downloadPath, bytesTotal = _ref35.bytesTotal, headers = _ref35.headers, callback = _ref35.callback, _ref35$format = _ref35.format, format = _ref35$format === void 0 ? "arrayBuffer" : _ref35$format, _ref35$chunked = _ref35.chunked, chunked = _ref35$chunked === void 0 ? false : _ref35$chunked;
|
|
1702
1718
|
if (!(chunked && !callback)) {
|
|
1703
|
-
|
|
1719
|
+
_context20.next = 1;
|
|
1704
1720
|
break;
|
|
1705
1721
|
}
|
|
1706
1722
|
throw Error("No callback specified for chunked download");
|
|
1707
|
-
case
|
|
1723
|
+
case 1:
|
|
1708
1724
|
// Must align chunk size with encryption block size
|
|
1709
1725
|
isReencryption = conk.public_key.startsWith("ktpk");
|
|
1710
1726
|
chunkSize = this.Crypto.EncryptedBlockSize(1000000, isReencryption);
|
|
1711
1727
|
bytesFinished = 0;
|
|
1712
1728
|
format = format.toLowerCase();
|
|
1713
1729
|
outputChunks = []; // Set up decryption stream
|
|
1714
|
-
|
|
1730
|
+
_context20.next = 2;
|
|
1715
1731
|
return this.Crypto.OpenDecryptionStream(conk);
|
|
1716
|
-
case
|
|
1717
|
-
stream =
|
|
1732
|
+
case 2:
|
|
1733
|
+
stream = _context20.sent;
|
|
1718
1734
|
stream.on("data", /*#__PURE__*/function () {
|
|
1719
|
-
var
|
|
1735
|
+
var _ref37 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee18(chunk) {
|
|
1720
1736
|
var arrayBuffer;
|
|
1721
|
-
return _regeneratorRuntime.wrap(function
|
|
1722
|
-
while (1) switch (
|
|
1737
|
+
return _regeneratorRuntime.wrap(function (_context19) {
|
|
1738
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1723
1739
|
case 0:
|
|
1724
1740
|
if (!chunked) {
|
|
1725
|
-
|
|
1741
|
+
_context19.next = 4;
|
|
1726
1742
|
break;
|
|
1727
1743
|
}
|
|
1728
1744
|
if (!(format !== "buffer")) {
|
|
1729
|
-
|
|
1745
|
+
_context19.next = 3;
|
|
1730
1746
|
break;
|
|
1731
1747
|
}
|
|
1732
1748
|
arrayBuffer = chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength);
|
|
1733
1749
|
if (!(format === "arraybuffer")) {
|
|
1734
|
-
|
|
1750
|
+
_context19.next = 1;
|
|
1735
1751
|
break;
|
|
1736
1752
|
}
|
|
1737
1753
|
chunk = arrayBuffer;
|
|
1738
|
-
|
|
1754
|
+
_context19.next = 3;
|
|
1739
1755
|
break;
|
|
1740
|
-
case
|
|
1741
|
-
|
|
1756
|
+
case 1:
|
|
1757
|
+
_context19.next = 2;
|
|
1742
1758
|
return _this2.utils.ResponseToFormat(format, new Response(arrayBuffer));
|
|
1743
|
-
case
|
|
1744
|
-
chunk =
|
|
1745
|
-
case
|
|
1759
|
+
case 2:
|
|
1760
|
+
chunk = _context19.sent;
|
|
1761
|
+
case 3:
|
|
1746
1762
|
callback({
|
|
1747
1763
|
bytesFinished: bytesFinished,
|
|
1748
1764
|
bytesTotal: bytesTotal,
|
|
1749
1765
|
chunk: chunk
|
|
1750
1766
|
});
|
|
1751
|
-
|
|
1767
|
+
_context19.next = 5;
|
|
1752
1768
|
break;
|
|
1753
|
-
case
|
|
1769
|
+
case 4:
|
|
1754
1770
|
if (callback) {
|
|
1755
1771
|
callback({
|
|
1756
1772
|
bytesFinished: bytesFinished,
|
|
@@ -1758,71 +1774,71 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
1758
1774
|
});
|
|
1759
1775
|
}
|
|
1760
1776
|
outputChunks.push(chunk);
|
|
1761
|
-
case
|
|
1777
|
+
case 5:
|
|
1762
1778
|
case "end":
|
|
1763
|
-
return
|
|
1779
|
+
return _context19.stop();
|
|
1764
1780
|
}
|
|
1765
|
-
},
|
|
1781
|
+
}, _callee18);
|
|
1766
1782
|
}));
|
|
1767
|
-
return function (
|
|
1768
|
-
return
|
|
1783
|
+
return function (_x20) {
|
|
1784
|
+
return _ref37.apply(this, arguments);
|
|
1769
1785
|
};
|
|
1770
1786
|
}());
|
|
1771
1787
|
totalChunks = Math.ceil(bytesTotal / chunkSize);
|
|
1772
1788
|
i = 0;
|
|
1773
|
-
case
|
|
1789
|
+
case 3:
|
|
1774
1790
|
if (!(i < totalChunks)) {
|
|
1775
|
-
|
|
1791
|
+
_context20.next = 7;
|
|
1776
1792
|
break;
|
|
1777
1793
|
}
|
|
1778
1794
|
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
1779
|
-
|
|
1795
|
+
_context20.next = 4;
|
|
1780
1796
|
return this.HttpClient.Request({
|
|
1781
1797
|
headers: headers,
|
|
1782
1798
|
method: "GET",
|
|
1783
1799
|
path: downloadPath
|
|
1784
1800
|
});
|
|
1785
|
-
case
|
|
1786
|
-
response =
|
|
1801
|
+
case 4:
|
|
1802
|
+
response = _context20.sent;
|
|
1787
1803
|
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1804
|
+
_t88 = stream;
|
|
1805
|
+
_t89 = Uint8Array;
|
|
1806
|
+
_context20.next = 5;
|
|
1791
1807
|
return response.arrayBuffer();
|
|
1792
|
-
case
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
case
|
|
1808
|
+
case 5:
|
|
1809
|
+
_t90 = _context20.sent;
|
|
1810
|
+
_t91 = new _t89(_t90);
|
|
1811
|
+
_t88.write.call(_t88, _t91);
|
|
1812
|
+
case 6:
|
|
1797
1813
|
i++;
|
|
1798
|
-
|
|
1814
|
+
_context20.next = 3;
|
|
1799
1815
|
break;
|
|
1800
|
-
case
|
|
1816
|
+
case 7:
|
|
1801
1817
|
// Wait for decryption to complete
|
|
1802
1818
|
stream.end();
|
|
1803
|
-
|
|
1819
|
+
_context20.next = 8;
|
|
1804
1820
|
return new Promise(function (resolve) {
|
|
1805
1821
|
return stream.on("finish", function () {
|
|
1806
1822
|
resolve();
|
|
1807
1823
|
});
|
|
1808
1824
|
});
|
|
1809
|
-
case
|
|
1825
|
+
case 8:
|
|
1810
1826
|
if (chunked) {
|
|
1811
|
-
|
|
1827
|
+
_context20.next = 10;
|
|
1812
1828
|
break;
|
|
1813
1829
|
}
|
|
1814
|
-
|
|
1830
|
+
_context20.next = 9;
|
|
1815
1831
|
return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
|
|
1816
|
-
case
|
|
1817
|
-
return
|
|
1818
|
-
case
|
|
1832
|
+
case 9:
|
|
1833
|
+
return _context20.abrupt("return", _context20.sent);
|
|
1834
|
+
case 10:
|
|
1819
1835
|
case "end":
|
|
1820
|
-
return
|
|
1836
|
+
return _context20.stop();
|
|
1821
1837
|
}
|
|
1822
|
-
},
|
|
1838
|
+
}, _callee19, this);
|
|
1823
1839
|
}));
|
|
1824
|
-
return function (
|
|
1825
|
-
return
|
|
1840
|
+
return function (_x19) {
|
|
1841
|
+
return _ref36.apply(this, arguments);
|
|
1826
1842
|
};
|
|
1827
1843
|
}();
|
|
1828
1844
|
|
|
@@ -1840,50 +1856,50 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
1840
1856
|
* @returns {Promise<string>} - The part write token for the part draft
|
|
1841
1857
|
*/
|
|
1842
1858
|
exports.CreatePart = /*#__PURE__*/function () {
|
|
1843
|
-
var
|
|
1844
|
-
var libraryId, objectId, writeToken, encryption, path, openResponse;
|
|
1845
|
-
return _regeneratorRuntime.wrap(function
|
|
1846
|
-
while (1) switch (
|
|
1859
|
+
var _ref39 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref38) {
|
|
1860
|
+
var libraryId, objectId, writeToken, encryption, path, openResponse, _t92, _t93, _t94, _t95;
|
|
1861
|
+
return _regeneratorRuntime.wrap(function (_context21) {
|
|
1862
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1847
1863
|
case 0:
|
|
1848
|
-
libraryId =
|
|
1864
|
+
libraryId = _ref38.libraryId, objectId = _ref38.objectId, writeToken = _ref38.writeToken, encryption = _ref38.encryption;
|
|
1849
1865
|
ValidateParameters({
|
|
1850
1866
|
libraryId: libraryId,
|
|
1851
1867
|
objectId: objectId
|
|
1852
1868
|
});
|
|
1853
1869
|
ValidateWriteToken(writeToken);
|
|
1854
1870
|
path = UrlJoin("q", writeToken, "parts");
|
|
1855
|
-
|
|
1856
|
-
|
|
1871
|
+
_t92 = this.HttpClient;
|
|
1872
|
+
_context21.next = 1;
|
|
1857
1873
|
return this.authClient.AuthorizationHeader({
|
|
1858
1874
|
libraryId: libraryId,
|
|
1859
1875
|
objectId: objectId,
|
|
1860
1876
|
update: true,
|
|
1861
1877
|
encryption: encryption
|
|
1862
1878
|
});
|
|
1863
|
-
case
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
headers:
|
|
1879
|
+
case 1:
|
|
1880
|
+
_t93 = _context21.sent;
|
|
1881
|
+
_t94 = path;
|
|
1882
|
+
_t95 = {
|
|
1883
|
+
headers: _t93,
|
|
1868
1884
|
method: "POST",
|
|
1869
|
-
path:
|
|
1885
|
+
path: _t94,
|
|
1870
1886
|
bodyType: "BINARY",
|
|
1871
1887
|
body: "",
|
|
1872
1888
|
allowFailover: false
|
|
1873
1889
|
};
|
|
1874
|
-
|
|
1875
|
-
return
|
|
1876
|
-
case
|
|
1877
|
-
openResponse =
|
|
1878
|
-
return
|
|
1879
|
-
case
|
|
1890
|
+
_context21.next = 2;
|
|
1891
|
+
return _t92.RequestJsonBody.call(_t92, _t95);
|
|
1892
|
+
case 2:
|
|
1893
|
+
openResponse = _context21.sent;
|
|
1894
|
+
return _context21.abrupt("return", openResponse.part.write_token);
|
|
1895
|
+
case 3:
|
|
1880
1896
|
case "end":
|
|
1881
|
-
return
|
|
1897
|
+
return _context21.stop();
|
|
1882
1898
|
}
|
|
1883
|
-
},
|
|
1899
|
+
}, _callee20, this);
|
|
1884
1900
|
}));
|
|
1885
|
-
return function (
|
|
1886
|
-
return
|
|
1901
|
+
return function (_x21) {
|
|
1902
|
+
return _ref39.apply(this, arguments);
|
|
1887
1903
|
};
|
|
1888
1904
|
}();
|
|
1889
1905
|
|
|
@@ -1903,67 +1919,67 @@ exports.CreatePart = /*#__PURE__*/function () {
|
|
|
1903
1919
|
* @returns {Promise<string>} - The part write token for the part draft
|
|
1904
1920
|
*/
|
|
1905
1921
|
exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
1906
|
-
var
|
|
1907
|
-
var libraryId, objectId, writeToken, partWriteToken, chunk, encryption, conk, path;
|
|
1908
|
-
return _regeneratorRuntime.wrap(function
|
|
1909
|
-
while (1) switch (
|
|
1922
|
+
var _ref41 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref40) {
|
|
1923
|
+
var libraryId, objectId, writeToken, partWriteToken, chunk, encryption, conk, path, _t96, _t97, _t98, _t99, _t100, _t101, _t102;
|
|
1924
|
+
return _regeneratorRuntime.wrap(function (_context22) {
|
|
1925
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1910
1926
|
case 0:
|
|
1911
|
-
libraryId =
|
|
1927
|
+
libraryId = _ref40.libraryId, objectId = _ref40.objectId, writeToken = _ref40.writeToken, partWriteToken = _ref40.partWriteToken, chunk = _ref40.chunk, encryption = _ref40.encryption;
|
|
1912
1928
|
ValidateParameters({
|
|
1913
1929
|
libraryId: libraryId,
|
|
1914
1930
|
objectId: objectId
|
|
1915
1931
|
});
|
|
1916
1932
|
ValidateWriteToken(writeToken);
|
|
1917
1933
|
if (!(encryption && encryption !== "none")) {
|
|
1918
|
-
|
|
1934
|
+
_context22.next = 3;
|
|
1919
1935
|
break;
|
|
1920
1936
|
}
|
|
1921
|
-
|
|
1937
|
+
_context22.next = 1;
|
|
1922
1938
|
return this.EncryptionConk({
|
|
1923
1939
|
libraryId: libraryId,
|
|
1924
1940
|
objectId: objectId,
|
|
1925
1941
|
writeToken: writeToken
|
|
1926
1942
|
});
|
|
1927
|
-
case
|
|
1928
|
-
conk =
|
|
1929
|
-
|
|
1943
|
+
case 1:
|
|
1944
|
+
conk = _context22.sent;
|
|
1945
|
+
_context22.next = 2;
|
|
1930
1946
|
return this.Crypto.Encrypt(conk, chunk);
|
|
1931
|
-
case
|
|
1932
|
-
chunk =
|
|
1933
|
-
case
|
|
1947
|
+
case 2:
|
|
1948
|
+
chunk = _context22.sent;
|
|
1949
|
+
case 3:
|
|
1934
1950
|
path = UrlJoin("q", writeToken, "parts");
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1951
|
+
_t96 = this.utils;
|
|
1952
|
+
_t97 = this.HttpClient;
|
|
1953
|
+
_context22.next = 4;
|
|
1938
1954
|
return this.authClient.AuthorizationHeader({
|
|
1939
1955
|
libraryId: libraryId,
|
|
1940
1956
|
objectId: objectId,
|
|
1941
1957
|
update: true,
|
|
1942
1958
|
encryption: encryption
|
|
1943
1959
|
});
|
|
1944
|
-
case
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
headers:
|
|
1960
|
+
case 4:
|
|
1961
|
+
_t98 = _context22.sent;
|
|
1962
|
+
_t99 = UrlJoin(path, partWriteToken);
|
|
1963
|
+
_t100 = chunk;
|
|
1964
|
+
_t101 = {
|
|
1965
|
+
headers: _t98,
|
|
1950
1966
|
method: "POST",
|
|
1951
|
-
path:
|
|
1952
|
-
body:
|
|
1967
|
+
path: _t99,
|
|
1968
|
+
body: _t100,
|
|
1953
1969
|
bodyType: "BINARY",
|
|
1954
1970
|
allowFailover: false
|
|
1955
1971
|
};
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
return
|
|
1959
|
-
case
|
|
1972
|
+
_t102 = _t97.Request.call(_t97, _t101);
|
|
1973
|
+
_context22.next = 5;
|
|
1974
|
+
return _t96.ResponseToJson.call(_t96, _t102);
|
|
1975
|
+
case 5:
|
|
1960
1976
|
case "end":
|
|
1961
|
-
return
|
|
1977
|
+
return _context22.stop();
|
|
1962
1978
|
}
|
|
1963
|
-
},
|
|
1979
|
+
}, _callee21, this);
|
|
1964
1980
|
}));
|
|
1965
|
-
return function (
|
|
1966
|
-
return
|
|
1981
|
+
return function (_x22) {
|
|
1982
|
+
return _ref41.apply(this, arguments);
|
|
1967
1983
|
};
|
|
1968
1984
|
}();
|
|
1969
1985
|
|
|
@@ -1982,49 +1998,49 @@ exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
|
1982
1998
|
* @returns {Promise<object>} - The finalize response for the new part
|
|
1983
1999
|
*/
|
|
1984
2000
|
exports.FinalizePart = /*#__PURE__*/function () {
|
|
1985
|
-
var
|
|
1986
|
-
var libraryId, objectId, writeToken, partWriteToken, encryption, path;
|
|
1987
|
-
return _regeneratorRuntime.wrap(function
|
|
1988
|
-
while (1) switch (
|
|
2001
|
+
var _ref43 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref42) {
|
|
2002
|
+
var libraryId, objectId, writeToken, partWriteToken, encryption, path, _t103, _t104, _t105, _t106;
|
|
2003
|
+
return _regeneratorRuntime.wrap(function (_context23) {
|
|
2004
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1989
2005
|
case 0:
|
|
1990
|
-
libraryId =
|
|
2006
|
+
libraryId = _ref42.libraryId, objectId = _ref42.objectId, writeToken = _ref42.writeToken, partWriteToken = _ref42.partWriteToken, encryption = _ref42.encryption;
|
|
1991
2007
|
ValidateParameters({
|
|
1992
2008
|
libraryId: libraryId,
|
|
1993
2009
|
objectId: objectId
|
|
1994
2010
|
});
|
|
1995
2011
|
ValidateWriteToken(writeToken);
|
|
1996
2012
|
path = UrlJoin("q", writeToken, "parts");
|
|
1997
|
-
|
|
1998
|
-
|
|
2013
|
+
_t103 = this.HttpClient;
|
|
2014
|
+
_context23.next = 1;
|
|
1999
2015
|
return this.authClient.AuthorizationHeader({
|
|
2000
2016
|
libraryId: libraryId,
|
|
2001
2017
|
objectId: objectId,
|
|
2002
2018
|
update: true,
|
|
2003
2019
|
encryption: encryption
|
|
2004
2020
|
});
|
|
2005
|
-
case
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
headers:
|
|
2021
|
+
case 1:
|
|
2022
|
+
_t104 = _context23.sent;
|
|
2023
|
+
_t105 = UrlJoin(path, partWriteToken);
|
|
2024
|
+
_t106 = {
|
|
2025
|
+
headers: _t104,
|
|
2010
2026
|
method: "POST",
|
|
2011
|
-
path:
|
|
2027
|
+
path: _t105,
|
|
2012
2028
|
bodyType: "BINARY",
|
|
2013
2029
|
body: "",
|
|
2014
2030
|
allowFailover: false
|
|
2015
2031
|
};
|
|
2016
|
-
|
|
2017
|
-
return
|
|
2018
|
-
case
|
|
2019
|
-
return
|
|
2020
|
-
case
|
|
2032
|
+
_context23.next = 2;
|
|
2033
|
+
return _t103.RequestJsonBody.call(_t103, _t106);
|
|
2034
|
+
case 2:
|
|
2035
|
+
return _context23.abrupt("return", _context23.sent);
|
|
2036
|
+
case 3:
|
|
2021
2037
|
case "end":
|
|
2022
|
-
return
|
|
2038
|
+
return _context23.stop();
|
|
2023
2039
|
}
|
|
2024
|
-
},
|
|
2040
|
+
}, _callee22, this);
|
|
2025
2041
|
}));
|
|
2026
|
-
return function (
|
|
2027
|
-
return
|
|
2042
|
+
return function (_x23) {
|
|
2043
|
+
return _ref43.apply(this, arguments);
|
|
2028
2044
|
};
|
|
2029
2045
|
}();
|
|
2030
2046
|
|
|
@@ -2050,26 +2066,26 @@ exports.FinalizePart = /*#__PURE__*/function () {
|
|
|
2050
2066
|
* @returns {Promise<Object>} - Response containing information about the uploaded part
|
|
2051
2067
|
*/
|
|
2052
2068
|
exports.UploadPart = /*#__PURE__*/function () {
|
|
2053
|
-
var
|
|
2054
|
-
var libraryId, objectId, writeToken, data,
|
|
2055
|
-
return _regeneratorRuntime.wrap(function
|
|
2056
|
-
while (1) switch (
|
|
2069
|
+
var _ref45 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref44) {
|
|
2070
|
+
var libraryId, objectId, writeToken, data, _ref44$encryption, encryption, _ref44$chunkSize, chunkSize, callback, partWriteToken, size, i, chunk;
|
|
2071
|
+
return _regeneratorRuntime.wrap(function (_context24) {
|
|
2072
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2057
2073
|
case 0:
|
|
2058
|
-
libraryId =
|
|
2074
|
+
libraryId = _ref44.libraryId, objectId = _ref44.objectId, writeToken = _ref44.writeToken, data = _ref44.data, _ref44$encryption = _ref44.encryption, encryption = _ref44$encryption === void 0 ? "none" : _ref44$encryption, _ref44$chunkSize = _ref44.chunkSize, chunkSize = _ref44$chunkSize === void 0 ? 10000000 : _ref44$chunkSize, callback = _ref44.callback;
|
|
2059
2075
|
ValidateParameters({
|
|
2060
2076
|
libraryId: libraryId,
|
|
2061
2077
|
objectId: objectId
|
|
2062
2078
|
});
|
|
2063
2079
|
ValidateWriteToken(writeToken);
|
|
2064
|
-
|
|
2080
|
+
_context24.next = 1;
|
|
2065
2081
|
return this.CreatePart({
|
|
2066
2082
|
libraryId: libraryId,
|
|
2067
2083
|
objectId: objectId,
|
|
2068
2084
|
writeToken: writeToken,
|
|
2069
2085
|
encryption: encryption
|
|
2070
2086
|
});
|
|
2071
|
-
case
|
|
2072
|
-
partWriteToken =
|
|
2087
|
+
case 1:
|
|
2088
|
+
partWriteToken = _context24.sent;
|
|
2073
2089
|
size = data.length || data.byteLength || data.size;
|
|
2074
2090
|
if (callback) {
|
|
2075
2091
|
callback({
|
|
@@ -2078,13 +2094,13 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2078
2094
|
});
|
|
2079
2095
|
}
|
|
2080
2096
|
i = 0;
|
|
2081
|
-
case
|
|
2097
|
+
case 2:
|
|
2082
2098
|
if (!(i < size)) {
|
|
2083
|
-
|
|
2099
|
+
_context24.next = 5;
|
|
2084
2100
|
break;
|
|
2085
2101
|
}
|
|
2086
2102
|
chunk = data.slice(i, i + chunkSize);
|
|
2087
|
-
|
|
2103
|
+
_context24.next = 3;
|
|
2088
2104
|
return this.UploadPartChunk({
|
|
2089
2105
|
libraryId: libraryId,
|
|
2090
2106
|
objectId: objectId,
|
|
@@ -2093,19 +2109,19 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2093
2109
|
chunk: chunk,
|
|
2094
2110
|
encryption: encryption
|
|
2095
2111
|
});
|
|
2096
|
-
case
|
|
2112
|
+
case 3:
|
|
2097
2113
|
if (callback) {
|
|
2098
2114
|
callback({
|
|
2099
2115
|
bytesFinished: Math.min(i + chunkSize, size),
|
|
2100
2116
|
bytesTotal: size
|
|
2101
2117
|
});
|
|
2102
2118
|
}
|
|
2103
|
-
case
|
|
2119
|
+
case 4:
|
|
2104
2120
|
i += chunkSize;
|
|
2105
|
-
|
|
2121
|
+
_context24.next = 2;
|
|
2106
2122
|
break;
|
|
2107
|
-
case
|
|
2108
|
-
|
|
2123
|
+
case 5:
|
|
2124
|
+
_context24.next = 6;
|
|
2109
2125
|
return this.FinalizePart({
|
|
2110
2126
|
libraryId: libraryId,
|
|
2111
2127
|
objectId: objectId,
|
|
@@ -2113,16 +2129,16 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2113
2129
|
partWriteToken: partWriteToken,
|
|
2114
2130
|
encryption: encryption
|
|
2115
2131
|
});
|
|
2116
|
-
case
|
|
2117
|
-
return
|
|
2118
|
-
case
|
|
2132
|
+
case 6:
|
|
2133
|
+
return _context24.abrupt("return", _context24.sent);
|
|
2134
|
+
case 7:
|
|
2119
2135
|
case "end":
|
|
2120
|
-
return
|
|
2136
|
+
return _context24.stop();
|
|
2121
2137
|
}
|
|
2122
|
-
},
|
|
2138
|
+
}, _callee23, this);
|
|
2123
2139
|
}));
|
|
2124
|
-
return function (
|
|
2125
|
-
return
|
|
2140
|
+
return function (_x24) {
|
|
2141
|
+
return _ref45.apply(this, arguments);
|
|
2126
2142
|
};
|
|
2127
2143
|
}();
|
|
2128
2144
|
|
|
@@ -2138,12 +2154,12 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2138
2154
|
* @param {string} partHash - Hash of the part to delete
|
|
2139
2155
|
*/
|
|
2140
2156
|
exports.DeletePart = /*#__PURE__*/function () {
|
|
2141
|
-
var
|
|
2142
|
-
var libraryId, objectId, writeToken, partHash, path;
|
|
2143
|
-
return _regeneratorRuntime.wrap(function
|
|
2144
|
-
while (1) switch (
|
|
2157
|
+
var _ref47 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref46) {
|
|
2158
|
+
var libraryId, objectId, writeToken, partHash, path, _t107, _t108, _t109, _t110;
|
|
2159
|
+
return _regeneratorRuntime.wrap(function (_context25) {
|
|
2160
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2145
2161
|
case 0:
|
|
2146
|
-
libraryId =
|
|
2162
|
+
libraryId = _ref46.libraryId, objectId = _ref46.objectId, writeToken = _ref46.writeToken, partHash = _ref46.partHash;
|
|
2147
2163
|
ValidateParameters({
|
|
2148
2164
|
libraryId: libraryId,
|
|
2149
2165
|
objectId: objectId
|
|
@@ -2151,31 +2167,31 @@ exports.DeletePart = /*#__PURE__*/function () {
|
|
|
2151
2167
|
ValidateWriteToken(writeToken);
|
|
2152
2168
|
ValidatePartHash(partHash);
|
|
2153
2169
|
path = UrlJoin("q", writeToken, "parts", partHash);
|
|
2154
|
-
|
|
2155
|
-
|
|
2170
|
+
_t107 = this.HttpClient;
|
|
2171
|
+
_context25.next = 1;
|
|
2156
2172
|
return this.authClient.AuthorizationHeader({
|
|
2157
2173
|
libraryId: libraryId,
|
|
2158
2174
|
objectId: objectId,
|
|
2159
2175
|
update: true
|
|
2160
2176
|
});
|
|
2161
|
-
case
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
headers:
|
|
2177
|
+
case 1:
|
|
2178
|
+
_t108 = _context25.sent;
|
|
2179
|
+
_t109 = path;
|
|
2180
|
+
_t110 = {
|
|
2181
|
+
headers: _t108,
|
|
2166
2182
|
method: "DELETE",
|
|
2167
|
-
path:
|
|
2183
|
+
path: _t109,
|
|
2168
2184
|
allowFailover: false
|
|
2169
2185
|
};
|
|
2170
|
-
|
|
2171
|
-
return
|
|
2172
|
-
case
|
|
2186
|
+
_context25.next = 2;
|
|
2187
|
+
return _t107.Request.call(_t107, _t110);
|
|
2188
|
+
case 2:
|
|
2173
2189
|
case "end":
|
|
2174
|
-
return
|
|
2190
|
+
return _context25.stop();
|
|
2175
2191
|
}
|
|
2176
|
-
},
|
|
2192
|
+
}, _callee24, this);
|
|
2177
2193
|
}));
|
|
2178
|
-
return function (
|
|
2179
|
-
return
|
|
2194
|
+
return function (_x25) {
|
|
2195
|
+
return _ref47.apply(this, arguments);
|
|
2180
2196
|
};
|
|
2181
2197
|
}();
|