@eluvio/elv-client-js 4.2.30 → 4.2.32
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/ContentObjectVerification.js +281 -0
- package/dist/src/ElvClient.js +275 -355
- package/dist/src/EthClient.js +2 -3
- package/dist/src/FrameClient.js +1 -1
- package/dist/src/client/ABRPublishing.js +60 -71
- package/dist/src/client/ContentAccess.js +204 -298
- package/dist/src/client/Files.js +844 -1400
- package/dist/src/client/LiveConf.js +37 -54
- package/dist/src/client/LiveStream.js +81 -123
- package/package.json +1 -1
- package/src/AuthorizationClient.js +5 -0
- package/src/ElvClient.js +28 -5
- package/src/FrameClient.js +16 -0
- package/src/client/ContentAccess.js +192 -0
- package/src/client/ContentManagement.js +366 -9
- package/src/client/LiveStream.js +148 -0
- package/testScripts/Test.js +14 -2
- package/utilities/ObjectInfo.js +99 -0
- package/utilities/TenantContent.js +136 -0
package/dist/src/client/Files.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
|
|
2
1
|
var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
|
|
3
2
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
4
3
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
5
4
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
6
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
7
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
7
|
/**
|
|
@@ -28,12 +24,6 @@ var _require = require("../Validation"),
|
|
|
28
24
|
ValidateWriteToken = _require.ValidateWriteToken,
|
|
29
25
|
ValidatePartHash = _require.ValidatePartHash,
|
|
30
26
|
ValidateParameters = _require.ValidateParameters;
|
|
31
|
-
var JobStatus = Object.freeze({
|
|
32
|
-
STOPPED: "STOPPED",
|
|
33
|
-
FAILED: "FAILED",
|
|
34
|
-
IN_PROGRESS: "IN_PROGRESS",
|
|
35
|
-
COMPLETED: "COMPLETED"
|
|
36
|
-
});
|
|
37
27
|
|
|
38
28
|
/* Files */
|
|
39
29
|
|
|
@@ -94,7 +84,7 @@ exports.ListFiles = /*#__PURE__*/function () {
|
|
|
94
84
|
}();
|
|
95
85
|
|
|
96
86
|
/**
|
|
97
|
-
*
|
|
87
|
+
* Copy/reference files from S3 to a content object.
|
|
98
88
|
*
|
|
99
89
|
* S3 authentication is done by either providing an access key and secret or a presigned URL. The credentials will not be stored (neither in the client nor in the Fabric)
|
|
100
90
|
*
|
|
@@ -102,12 +92,12 @@ exports.ListFiles = /*#__PURE__*/function () {
|
|
|
102
92
|
*
|
|
103
93
|
* Expected format of fileInfo:
|
|
104
94
|
*
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
[
|
|
96
|
+
{
|
|
97
|
+
path: string,
|
|
98
|
+
source: string // either a full path e.g. "s3://BUCKET_NAME/path..." or just the path part without "s3://BUCKET_NAME/"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
111
101
|
*
|
|
112
102
|
* @memberof module:ElvClient/Files+Parts
|
|
113
103
|
* @methodGroup Files
|
|
@@ -115,27 +105,25 @@ exports.ListFiles = /*#__PURE__*/function () {
|
|
|
115
105
|
* @param {string} libraryId - ID of the library
|
|
116
106
|
* @param {string} objectId - ID of the object
|
|
117
107
|
* @param {string} writeToken - Write token of the draft
|
|
118
|
-
* @param {string
|
|
119
|
-
* @param {string
|
|
108
|
+
* @param {string} region - AWS region to use
|
|
109
|
+
* @param {string} bucket - AWS bucket to use
|
|
120
110
|
* @param {Array<Object>} fileInfo - List of files to reference/copy
|
|
121
|
-
* @param {string
|
|
122
|
-
* @param {string
|
|
111
|
+
* @param {string} accessKey - AWS access key
|
|
112
|
+
* @param {string} secret - AWS secret
|
|
123
113
|
* @param {string=} signedUrl
|
|
124
114
|
* @param {string} encryption="none" - Encryption for uploaded files (copy only) - cgck | none
|
|
125
115
|
* @param {boolean} copy=false - If true, will copy the data from S3 into the fabric. Otherwise, a reference to the content will be made.
|
|
126
|
-
* @param {boolean} resume=false - If true, will resume the file jobs stopped
|
|
127
116
|
* @param {function=} callback - If specified, will be periodically called with current upload status
|
|
128
117
|
* - Arguments (copy): { done: boolean, uploaded: number, total: number, uploadedFiles: number, totalFiles: number, fileStatus: Object }
|
|
129
118
|
* - Arguments (reference): { done: boolean, uploadedFiles: number, totalFiles: number }
|
|
130
119
|
*/
|
|
131
120
|
exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
132
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
133
|
-
var
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
121
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
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 _callee2$(_context2) {
|
|
124
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
137
125
|
case 0:
|
|
138
|
-
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,
|
|
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;
|
|
139
127
|
ValidateParameters({
|
|
140
128
|
libraryId: libraryId,
|
|
141
129
|
objectId: objectId
|
|
@@ -146,65 +134,71 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
146
134
|
i = 0;
|
|
147
135
|
case 5:
|
|
148
136
|
if (!(i < fileInfo.length)) {
|
|
149
|
-
|
|
137
|
+
_context2.next = 18;
|
|
150
138
|
break;
|
|
151
139
|
}
|
|
152
140
|
fileSourcePath = fileInfo[i].source;
|
|
153
141
|
s3prefixMatch = s3prefixRegex.exec(fileSourcePath);
|
|
154
142
|
if (!s3prefixMatch) {
|
|
155
|
-
|
|
143
|
+
_context2.next = 15;
|
|
156
144
|
break;
|
|
157
145
|
}
|
|
158
146
|
bucketName = s3prefixMatch[1];
|
|
159
147
|
if (!(bucketName !== bucket)) {
|
|
160
|
-
|
|
148
|
+
_context2.next = 14;
|
|
161
149
|
break;
|
|
162
150
|
}
|
|
163
151
|
throw Error("Full S3 file path \"" + fileSourcePath + "\" specified, but does not match provided bucket name '" + bucket + "'");
|
|
164
|
-
case
|
|
152
|
+
case 14:
|
|
165
153
|
// strip prefix
|
|
166
154
|
fileInfo[i].source = fileSourcePath.replace(s3prefixRegex, "");
|
|
167
|
-
case
|
|
155
|
+
case 15:
|
|
168
156
|
i++;
|
|
169
|
-
|
|
157
|
+
_context2.next = 5;
|
|
170
158
|
break;
|
|
171
|
-
case
|
|
172
|
-
|
|
159
|
+
case 18:
|
|
160
|
+
if (copy) {
|
|
161
|
+
this.Log("Copying files from S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
162
|
+
} else {
|
|
163
|
+
this.Log("Adding links to files in S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
164
|
+
}
|
|
173
165
|
if (!(encryption === "cgck")) {
|
|
174
|
-
|
|
166
|
+
_context2.next = 25;
|
|
175
167
|
break;
|
|
176
168
|
}
|
|
177
|
-
|
|
169
|
+
_context2.next = 22;
|
|
178
170
|
return this.EncryptionConk({
|
|
179
171
|
libraryId: libraryId,
|
|
180
172
|
objectId: objectId,
|
|
181
173
|
writeToken: writeToken
|
|
182
174
|
});
|
|
183
|
-
case
|
|
184
|
-
conk =
|
|
175
|
+
case 22:
|
|
176
|
+
conk = _context2.sent;
|
|
185
177
|
conk = _objectSpread(_objectSpread({}, conk), {}, {
|
|
186
178
|
secret_key: ""
|
|
187
179
|
});
|
|
188
180
|
encryption_key = "kp__".concat(this.utils.B58(Buffer.from(JSON.stringify(conk))));
|
|
189
|
-
case
|
|
190
|
-
cloudCredentials =
|
|
191
|
-
signed_url: signedUrl
|
|
192
|
-
} : {
|
|
181
|
+
case 25:
|
|
182
|
+
cloudCredentials = {
|
|
193
183
|
access_key_id: accessKey,
|
|
194
184
|
secret_access_key: secret
|
|
195
185
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
if (bucket) remoteAccess.path = bucket;
|
|
202
|
-
if (region) remoteAccess.storage_endpoint = {
|
|
203
|
-
region: region
|
|
204
|
-
};
|
|
186
|
+
if (signedUrl) {
|
|
187
|
+
cloudCredentials = {
|
|
188
|
+
signed_url: signedUrl
|
|
189
|
+
};
|
|
190
|
+
}
|
|
205
191
|
defaults = {
|
|
206
192
|
encryption_key: encryption_key,
|
|
207
|
-
access:
|
|
193
|
+
access: {
|
|
194
|
+
protocol: "s3",
|
|
195
|
+
platform: "aws",
|
|
196
|
+
path: bucket,
|
|
197
|
+
storage_endpoint: {
|
|
198
|
+
region: region
|
|
199
|
+
},
|
|
200
|
+
cloud_credentials: cloudCredentials
|
|
201
|
+
}
|
|
208
202
|
};
|
|
209
203
|
ops = fileInfo.map(function (info) {
|
|
210
204
|
if (copy) {
|
|
@@ -229,242 +223,94 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
229
223
|
}
|
|
230
224
|
};
|
|
231
225
|
}
|
|
226
|
+
}); // eslint-disable-next-line no-unused-vars
|
|
227
|
+
_context2.next = 31;
|
|
228
|
+
return this.CreateFileUploadJob({
|
|
229
|
+
libraryId: libraryId,
|
|
230
|
+
objectId: objectId,
|
|
231
|
+
writeToken: writeToken,
|
|
232
|
+
ops: ops,
|
|
233
|
+
defaults: defaults
|
|
232
234
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
uploadId = _ref5.uploadId;
|
|
240
|
-
case 1:
|
|
241
|
-
if (!true) {
|
|
242
|
-
_context2.next = 24;
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
_context2.next = 4;
|
|
246
|
-
return new Promise(function (resolve) {
|
|
247
|
-
return setTimeout(resolve, 1000);
|
|
248
|
-
});
|
|
249
|
-
case 4:
|
|
250
|
-
_context2.next = 6;
|
|
251
|
-
return _this.UploadStatus({
|
|
252
|
-
libraryId: libraryId,
|
|
253
|
-
objectId: objectId,
|
|
254
|
-
writeToken: writeToken,
|
|
255
|
-
uploadId: uploadId
|
|
256
|
-
});
|
|
257
|
-
case 6:
|
|
258
|
-
status = _context2.sent;
|
|
259
|
-
if (!(status.errors && status.errors.length >= 1)) {
|
|
260
|
-
_context2.next = 11;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
throw new Error(status.errors.join("\n"));
|
|
264
|
-
case 11:
|
|
265
|
-
if (!status.error) {
|
|
266
|
-
_context2.next = 16;
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
_this.Log("S3 file upload failed:\n".concat(JSON.stringify(status, null, 2)));
|
|
270
|
-
throw new Error(status.error);
|
|
271
|
-
case 16:
|
|
272
|
-
if (!(status.status.toLowerCase() === "failed")) {
|
|
273
|
-
_context2.next = 18;
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
throw new Error("File upload failed");
|
|
277
|
-
case 18:
|
|
278
|
-
done = false;
|
|
279
|
-
if (copy) {
|
|
280
|
-
done = status.ingest_copy.done;
|
|
281
|
-
if (callback) {
|
|
282
|
-
progress = status.ingest_copy.progress;
|
|
283
|
-
callback({
|
|
284
|
-
done: done,
|
|
285
|
-
uploaded: progress.bytes.completed,
|
|
286
|
-
total: progress.bytes.total,
|
|
287
|
-
uploadedFiles: progress.files.completed,
|
|
288
|
-
totalFiles: progress.files.total,
|
|
289
|
-
fileStatus: progress.files.details
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
} else {
|
|
293
|
-
done = status.add_reference.done;
|
|
294
|
-
if (callback) {
|
|
295
|
-
_progress = status.add_reference.progress;
|
|
296
|
-
callback({
|
|
297
|
-
done: done,
|
|
298
|
-
uploadedFiles: _progress.completed,
|
|
299
|
-
totalFiles: _progress.total
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (!done) {
|
|
304
|
-
_context2.next = 22;
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
return _context2.abrupt("break", 24);
|
|
308
|
-
case 22:
|
|
309
|
-
_context2.next = 1;
|
|
310
|
-
break;
|
|
311
|
-
case 24:
|
|
312
|
-
case "end":
|
|
313
|
-
return _context2.stop();
|
|
314
|
-
}
|
|
315
|
-
}, _callee2);
|
|
316
|
-
}));
|
|
317
|
-
return function trackUploadStatus(_x3) {
|
|
318
|
-
return _ref6.apply(this, arguments);
|
|
319
|
-
};
|
|
320
|
-
}();
|
|
321
|
-
if (!resume) {
|
|
322
|
-
_context6.next = 50;
|
|
235
|
+
case 31:
|
|
236
|
+
_yield$this$CreateFil = _context2.sent;
|
|
237
|
+
id = _yield$this$CreateFil.id;
|
|
238
|
+
case 33:
|
|
239
|
+
if (!true) {
|
|
240
|
+
_context2.next = 56;
|
|
323
241
|
break;
|
|
324
242
|
}
|
|
325
|
-
|
|
326
|
-
return
|
|
243
|
+
_context2.next = 36;
|
|
244
|
+
return new Promise(function (resolve) {
|
|
245
|
+
return setTimeout(resolve, 1000);
|
|
246
|
+
});
|
|
247
|
+
case 36:
|
|
248
|
+
_context2.next = 38;
|
|
249
|
+
return this.UploadStatus({
|
|
327
250
|
libraryId: libraryId,
|
|
328
251
|
objectId: objectId,
|
|
329
252
|
writeToken: writeToken,
|
|
330
|
-
|
|
253
|
+
uploadId: id
|
|
331
254
|
});
|
|
332
|
-
case
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
acc[job.status].set(job.id, true);
|
|
337
|
-
return acc;
|
|
338
|
-
}, {});
|
|
339
|
-
resumeAndTrack = /*#__PURE__*/function () {
|
|
340
|
-
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobIds) {
|
|
341
|
-
var responses;
|
|
342
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
343
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
344
|
-
case 0:
|
|
345
|
-
_context4.next = 2;
|
|
346
|
-
return _this.ResumeFileUploadJob({
|
|
347
|
-
libraryId: libraryId,
|
|
348
|
-
objectId: objectId,
|
|
349
|
-
writeToken: writeToken,
|
|
350
|
-
ops: ops,
|
|
351
|
-
defaults: defaults,
|
|
352
|
-
encryption: encryption,
|
|
353
|
-
stoppedOrFailedJobIds: jobIds
|
|
354
|
-
});
|
|
355
|
-
case 2:
|
|
356
|
-
responses = _context4.sent;
|
|
357
|
-
_context4.next = 5;
|
|
358
|
-
return _this.utils.LimitedMap(5, responses, /*#__PURE__*/function () {
|
|
359
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(res) {
|
|
360
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
361
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
362
|
-
case 0:
|
|
363
|
-
_this.Log("Tracking resumed job id: ".concat(res.id));
|
|
364
|
-
_context3.next = 3;
|
|
365
|
-
return trackUploadStatus({
|
|
366
|
-
uploadId: res.id
|
|
367
|
-
});
|
|
368
|
-
case 3:
|
|
369
|
-
case "end":
|
|
370
|
-
return _context3.stop();
|
|
371
|
-
}
|
|
372
|
-
}, _callee3);
|
|
373
|
-
}));
|
|
374
|
-
return function (_x5) {
|
|
375
|
-
return _ref8.apply(this, arguments);
|
|
376
|
-
};
|
|
377
|
-
}());
|
|
378
|
-
case 5:
|
|
379
|
-
case "end":
|
|
380
|
-
return _context4.stop();
|
|
381
|
-
}
|
|
382
|
-
}, _callee4);
|
|
383
|
-
}));
|
|
384
|
-
return function resumeAndTrack(_x4) {
|
|
385
|
-
return _ref7.apply(this, arguments);
|
|
386
|
-
};
|
|
387
|
-
}();
|
|
388
|
-
_i = 0, _arr = [JobStatus.STOPPED, JobStatus.FAILED];
|
|
389
|
-
case 37:
|
|
390
|
-
if (!(_i < _arr.length)) {
|
|
391
|
-
_context6.next = 45;
|
|
255
|
+
case 38:
|
|
256
|
+
status = _context2.sent;
|
|
257
|
+
if (!(status.errors && status.errors.length > 1)) {
|
|
258
|
+
_context2.next = 43;
|
|
392
259
|
break;
|
|
393
260
|
}
|
|
394
|
-
status
|
|
395
|
-
|
|
396
|
-
|
|
261
|
+
throw status.errors.join("\n");
|
|
262
|
+
case 43:
|
|
263
|
+
if (!status.error) {
|
|
264
|
+
_context2.next = 48;
|
|
397
265
|
break;
|
|
398
266
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
case 42:
|
|
402
|
-
_i++;
|
|
403
|
-
_context6.next = 37;
|
|
404
|
-
break;
|
|
405
|
-
case 45:
|
|
406
|
-
trackOnlyEntries = Object.entries(jobsByStatus).filter(function (_ref9) {
|
|
407
|
-
var _ref10 = _slicedToArray(_ref9, 1),
|
|
408
|
-
status = _ref10[0];
|
|
409
|
-
return [JobStatus.IN_PROGRESS, JobStatus.COMPLETED].includes(status);
|
|
410
|
-
}).flatMap(function (_ref11) {
|
|
411
|
-
var _ref12 = _slicedToArray(_ref11, 2),
|
|
412
|
-
status = _ref12[0],
|
|
413
|
-
jobs = _ref12[1];
|
|
414
|
-
return _toConsumableArray(jobs.keys()).map(function (jobId) {
|
|
415
|
-
return {
|
|
416
|
-
status: status,
|
|
417
|
-
jobId: jobId
|
|
418
|
-
};
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
_context6.next = 48;
|
|
422
|
-
return this.utils.LimitedMap(5, trackOnlyEntries, /*#__PURE__*/function () {
|
|
423
|
-
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref13) {
|
|
424
|
-
var status, jobId;
|
|
425
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
426
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
427
|
-
case 0:
|
|
428
|
-
status = _ref13.status, jobId = _ref13.jobId;
|
|
429
|
-
_this.Log("Tracking ".concat(status.toLowerCase(), " job id: ").concat(jobId));
|
|
430
|
-
_context5.next = 4;
|
|
431
|
-
return trackUploadStatus({
|
|
432
|
-
uploadId: jobId
|
|
433
|
-
});
|
|
434
|
-
case 4:
|
|
435
|
-
case "end":
|
|
436
|
-
return _context5.stop();
|
|
437
|
-
}
|
|
438
|
-
}, _callee5);
|
|
439
|
-
}));
|
|
440
|
-
return function (_x6) {
|
|
441
|
-
return _ref14.apply(this, arguments);
|
|
442
|
-
};
|
|
443
|
-
}());
|
|
267
|
+
this.Log("S3 file upload failed:\n".concat(JSON.stringify(status, null, 2)));
|
|
268
|
+
throw status.error;
|
|
444
269
|
case 48:
|
|
445
|
-
|
|
446
|
-
|
|
270
|
+
if (!(status.status.toLowerCase() === "failed")) {
|
|
271
|
+
_context2.next = 50;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
throw "File upload failed";
|
|
447
275
|
case 50:
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
276
|
+
done = false;
|
|
277
|
+
if (copy) {
|
|
278
|
+
done = status.ingest_copy.done;
|
|
279
|
+
if (callback) {
|
|
280
|
+
progress = status.ingest_copy.progress;
|
|
281
|
+
callback({
|
|
282
|
+
done: done,
|
|
283
|
+
uploaded: progress.bytes.completed,
|
|
284
|
+
total: progress.bytes.total,
|
|
285
|
+
uploadedFiles: progress.files.completed,
|
|
286
|
+
totalFiles: progress.files.total,
|
|
287
|
+
fileStatus: progress.files.details
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
done = status.add_reference.done;
|
|
292
|
+
if (callback) {
|
|
293
|
+
_progress = status.add_reference.progress;
|
|
294
|
+
callback({
|
|
295
|
+
done: done,
|
|
296
|
+
uploadedFiles: _progress.completed,
|
|
297
|
+
totalFiles: _progress.total
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (!done) {
|
|
302
|
+
_context2.next = 54;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
return _context2.abrupt("break", 56);
|
|
306
|
+
case 54:
|
|
307
|
+
_context2.next = 33;
|
|
308
|
+
break;
|
|
463
309
|
case 56:
|
|
464
310
|
case "end":
|
|
465
|
-
return
|
|
311
|
+
return _context2.stop();
|
|
466
312
|
}
|
|
467
|
-
},
|
|
313
|
+
}, _callee2, this);
|
|
468
314
|
}));
|
|
469
315
|
return function (_x2) {
|
|
470
316
|
return _ref4.apply(this, arguments);
|
|
@@ -476,14 +322,14 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
476
322
|
*
|
|
477
323
|
* Expected format of fileInfo:
|
|
478
324
|
*
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
325
|
+
[
|
|
326
|
+
{
|
|
327
|
+
path: string,
|
|
328
|
+
mime_type: string,
|
|
329
|
+
size: number,
|
|
330
|
+
data: File | ArrayBuffer | Buffer | File Descriptor (Node)
|
|
331
|
+
}
|
|
332
|
+
]
|
|
487
333
|
*
|
|
488
334
|
*
|
|
489
335
|
* @memberof module:ElvClient/Files+Parts
|
|
@@ -493,19 +339,18 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
493
339
|
* @param {string} objectId - ID of the object
|
|
494
340
|
* @param {string} writeToken - Write token of the draft
|
|
495
341
|
* @param {Array<object>} fileInfo - List of files to upload, including their size, type, and contents
|
|
496
|
-
* @param {string} resume - Resume the upload jobs
|
|
497
342
|
* @param {string} encryption="none" - Encryption for uploaded files - cgck | none
|
|
498
343
|
* @param {function=} callback - If specified, will be called after each job segment is finished with the current upload progress
|
|
499
344
|
* - Format: {"filename1": {uploaded: number, total: number}, ...}
|
|
500
345
|
*/
|
|
501
346
|
exports.UploadFiles = /*#__PURE__*/function () {
|
|
502
|
-
var
|
|
503
|
-
var
|
|
504
|
-
var libraryId, objectId, writeToken, fileInfo,
|
|
505
|
-
return _regeneratorRuntime.wrap(function
|
|
506
|
-
while (1) switch (
|
|
347
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref5) {
|
|
348
|
+
var _this = this;
|
|
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 _callee6$(_context7) {
|
|
351
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
507
352
|
case 0:
|
|
508
|
-
libraryId =
|
|
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;
|
|
509
354
|
ValidateParameters({
|
|
510
355
|
libraryId: libraryId,
|
|
511
356
|
objectId: objectId
|
|
@@ -514,17 +359,17 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
514
359
|
ValidatePresence("fileInfo", fileInfo);
|
|
515
360
|
this.Log("Uploading files: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
516
361
|
if (!(encryption === "cgck")) {
|
|
517
|
-
|
|
362
|
+
_context7.next = 9;
|
|
518
363
|
break;
|
|
519
364
|
}
|
|
520
|
-
|
|
365
|
+
_context7.next = 8;
|
|
521
366
|
return this.EncryptionConk({
|
|
522
367
|
libraryId: libraryId,
|
|
523
368
|
objectId: objectId,
|
|
524
369
|
writeToken: writeToken
|
|
525
370
|
});
|
|
526
371
|
case 8:
|
|
527
|
-
conk =
|
|
372
|
+
conk = _context7.sent;
|
|
528
373
|
case 9:
|
|
529
374
|
// Extract file data into easily accessible hash while removing the data from the fileinfo for upload job creation
|
|
530
375
|
progress = {};
|
|
@@ -550,507 +395,294 @@ exports.UploadFiles = /*#__PURE__*/function () {
|
|
|
550
395
|
fileInfo.push(entry);
|
|
551
396
|
}
|
|
552
397
|
this.Log(fileInfo);
|
|
553
|
-
|
|
554
|
-
// On a fresh upload nothing has happened yet, so 0% is accurate. On resume, the real starting
|
|
555
|
-
// point isn't known until job status is fetched below, so skip this to avoid a misleading
|
|
556
|
-
// initial 0% line ahead of the actual (possibly much higher) baseline.
|
|
557
|
-
if (callback && !resume) {
|
|
398
|
+
if (callback) {
|
|
558
399
|
callback(progress);
|
|
559
400
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
_context15.next = 45;
|
|
563
|
-
break;
|
|
564
|
-
}
|
|
565
|
-
_context15.next = 20;
|
|
566
|
-
return this.ListFilesJob({
|
|
401
|
+
_context7.next = 18;
|
|
402
|
+
return this.CreateFileUploadJob({
|
|
567
403
|
libraryId: libraryId,
|
|
568
404
|
objectId: objectId,
|
|
569
405
|
writeToken: writeToken,
|
|
406
|
+
ops: fileInfo,
|
|
570
407
|
encryption: encryption
|
|
571
408
|
});
|
|
572
|
-
case
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
case 29:
|
|
590
|
-
resumeJobs = /*#__PURE__*/function () {
|
|
591
|
-
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(jobs) {
|
|
592
|
-
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
593
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
409
|
+
case 18:
|
|
410
|
+
_yield$this$CreateFil2 = _context7.sent;
|
|
411
|
+
id = _yield$this$CreateFil2.id;
|
|
412
|
+
jobs = _yield$this$CreateFil2.jobs;
|
|
413
|
+
this.Log("Upload ID: ".concat(id));
|
|
414
|
+
this.Log(jobs);
|
|
415
|
+
|
|
416
|
+
// How far encryption can get ahead of upload
|
|
417
|
+
bufferSize = 500 * 1024 * 1024;
|
|
418
|
+
jobSpecs = [];
|
|
419
|
+
prepared = 0;
|
|
420
|
+
uploaded = 0; // Insert the data to upload into the job spec, encrypting if necessary
|
|
421
|
+
PrepareJobs = /*#__PURE__*/function () {
|
|
422
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
423
|
+
var j, jobId, job, f, _fileInfo, data;
|
|
424
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
425
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
594
426
|
case 0:
|
|
595
|
-
|
|
596
|
-
|
|
427
|
+
j = 0;
|
|
428
|
+
case 1:
|
|
429
|
+
if (!(j < jobs.length)) {
|
|
430
|
+
_context3.next = 31;
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
case 2:
|
|
434
|
+
if (!(prepared - uploaded > bufferSize)) {
|
|
435
|
+
_context3.next = 7;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
_context3.next = 5;
|
|
439
|
+
return new Promise(function (resolve) {
|
|
440
|
+
return setTimeout(resolve, 500);
|
|
441
|
+
});
|
|
442
|
+
case 5:
|
|
443
|
+
_context3.next = 2;
|
|
444
|
+
break;
|
|
445
|
+
case 7:
|
|
446
|
+
// Retrieve job info
|
|
447
|
+
jobId = jobs[j];
|
|
448
|
+
_context3.next = 10;
|
|
449
|
+
return _this.UploadJobStatus({
|
|
597
450
|
libraryId: libraryId,
|
|
598
451
|
objectId: objectId,
|
|
599
452
|
writeToken: writeToken,
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
stoppedOrFailedJobIds: jobs
|
|
453
|
+
uploadId: id,
|
|
454
|
+
jobId: jobId
|
|
603
455
|
});
|
|
604
|
-
case
|
|
456
|
+
case 10:
|
|
457
|
+
job = _context3.sent;
|
|
458
|
+
f = 0;
|
|
459
|
+
case 12:
|
|
460
|
+
if (!(f < job.files.length)) {
|
|
461
|
+
_context3.next = 25;
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
_fileInfo = job.files[f];
|
|
465
|
+
data = void 0;
|
|
466
|
+
if (typeof fileDataMap[_fileInfo.path] === "number") {
|
|
467
|
+
// File descriptor - Read data from file
|
|
468
|
+
data = Buffer.alloc(_fileInfo.len);
|
|
469
|
+
fs.readSync(fileDataMap[_fileInfo.path], data, 0, _fileInfo.len, _fileInfo.off);
|
|
470
|
+
} else {
|
|
471
|
+
// Full data - Slice requested chunk
|
|
472
|
+
data = fileDataMap[_fileInfo.path].slice(_fileInfo.off, _fileInfo.off + _fileInfo.len);
|
|
473
|
+
}
|
|
474
|
+
if (!(encryption === "cgck")) {
|
|
475
|
+
_context3.next = 20;
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
_context3.next = 19;
|
|
479
|
+
return _this.Crypto.Encrypt(conk, data);
|
|
480
|
+
case 19:
|
|
481
|
+
data = _context3.sent;
|
|
482
|
+
case 20:
|
|
483
|
+
job.files[f].data = data;
|
|
484
|
+
prepared += _fileInfo.len;
|
|
485
|
+
case 22:
|
|
486
|
+
f++;
|
|
487
|
+
_context3.next = 12;
|
|
488
|
+
break;
|
|
489
|
+
case 25:
|
|
490
|
+
jobSpecs[j] = job;
|
|
491
|
+
|
|
492
|
+
// Wait for a bit to let upload start
|
|
493
|
+
_context3.next = 28;
|
|
494
|
+
return new Promise(function (resolve) {
|
|
495
|
+
return setTimeout(resolve, 50);
|
|
496
|
+
});
|
|
497
|
+
case 28:
|
|
498
|
+
j++;
|
|
499
|
+
_context3.next = 1;
|
|
500
|
+
break;
|
|
501
|
+
case 31:
|
|
605
502
|
case "end":
|
|
606
|
-
return
|
|
503
|
+
return _context3.stop();
|
|
607
504
|
}
|
|
608
|
-
},
|
|
505
|
+
}, _callee3);
|
|
609
506
|
}));
|
|
610
|
-
return function
|
|
611
|
-
return
|
|
507
|
+
return function PrepareJobs() {
|
|
508
|
+
return _ref7.apply(this, arguments);
|
|
612
509
|
};
|
|
613
|
-
}();
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
}
|
|
620
|
-
jobsToResume = _arr2[_i2];
|
|
621
|
-
if (!(jobsToResume.length > 0)) {
|
|
622
|
-
_context15.next = 36;
|
|
623
|
-
break;
|
|
624
|
-
}
|
|
625
|
-
_context15.next = 36;
|
|
626
|
-
return resumeJobs(jobsToResume);
|
|
627
|
-
case 36:
|
|
628
|
-
_i2++;
|
|
629
|
-
_context15.next = 31;
|
|
630
|
-
break;
|
|
631
|
-
case 39:
|
|
632
|
-
_context15.next = 41;
|
|
633
|
-
return this.utils.LimitedMap(5, resumeJobIds, /*#__PURE__*/function () {
|
|
634
|
-
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(uploadId) {
|
|
635
|
-
var result;
|
|
636
|
-
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
637
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
510
|
+
}();
|
|
511
|
+
UploadJob = /*#__PURE__*/function () {
|
|
512
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobId, j) {
|
|
513
|
+
var jobSpec, files, _loop, f;
|
|
514
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context5) {
|
|
515
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
638
516
|
case 0:
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
517
|
+
if (jobSpecs[j]) {
|
|
518
|
+
_context5.next = 5;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
_context5.next = 3;
|
|
522
|
+
return new Promise(function (resolve) {
|
|
523
|
+
return setTimeout(resolve, 500);
|
|
646
524
|
});
|
|
647
|
-
case
|
|
648
|
-
|
|
649
|
-
return _context8.abrupt("return", result.jobs);
|
|
650
|
-
case 4:
|
|
651
|
-
case "end":
|
|
652
|
-
return _context8.stop();
|
|
653
|
-
}
|
|
654
|
-
}, _callee8);
|
|
655
|
-
}));
|
|
656
|
-
return function (_x9) {
|
|
657
|
-
return _ref18.apply(this, arguments);
|
|
658
|
-
};
|
|
659
|
-
}());
|
|
660
|
-
case 41:
|
|
661
|
-
uploadJobsResults = _context15.sent;
|
|
662
|
-
resumeJobIds.forEach(function (uploadId, i) {
|
|
663
|
-
return idJobMap.set(uploadId, uploadJobsResults[i]);
|
|
664
|
-
});
|
|
665
|
-
_context15.next = 49;
|
|
666
|
-
break;
|
|
667
|
-
case 45:
|
|
668
|
-
_context15.next = 47;
|
|
669
|
-
return this.CreateFileUploadJob({
|
|
670
|
-
libraryId: libraryId,
|
|
671
|
-
objectId: objectId,
|
|
672
|
-
writeToken: writeToken,
|
|
673
|
-
ops: fileInfo,
|
|
674
|
-
encryption: encryption
|
|
675
|
-
});
|
|
676
|
-
case 47:
|
|
677
|
-
jobResponse = _context15.sent;
|
|
678
|
-
idJobMap.set(jobResponse.id, jobResponse.jobs);
|
|
679
|
-
case 49:
|
|
680
|
-
// How far encryption can get ahead of upload (500 MB)
|
|
681
|
-
bufferSize = 500 * 1024 * 1024; // Process each uploadId and its jobs
|
|
682
|
-
_iterator = _createForOfIteratorHelper(idJobMap.entries());
|
|
683
|
-
_context15.prev = 51;
|
|
684
|
-
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
685
|
-
var _step$value, uploadId, jobs, prepared, uploaded, jobSpecs, alreadyCreditedKeys, PrepareJobs, UploadJob, rateTestJobs, rates, j, start, elapsed, size, averageRate, concurrentUploads;
|
|
686
|
-
return _regeneratorRuntime.wrap(function _loop$(_context14) {
|
|
687
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
688
|
-
case 0:
|
|
689
|
-
_step$value = _slicedToArray(_step.value, 2), uploadId = _step$value[0], jobs = _step$value[1];
|
|
690
|
-
_this2.Log("Upload ID: ".concat(uploadId));
|
|
691
|
-
_this2.Log(jobs.length);
|
|
692
|
-
|
|
693
|
-
// Each upload ID gets its own counters
|
|
694
|
-
prepared = 0;
|
|
695
|
-
uploaded = 0;
|
|
696
|
-
jobSpecs = []; // `${jobId}:${path}` pairs already reflected in progress by the resume baseline scan below,
|
|
697
|
-
// so the normal per-chunk completion credit further down doesn't double-count them
|
|
698
|
-
// It stores the jobId whose remaining bytes = 0
|
|
699
|
-
alreadyCreditedKeys = new Set();
|
|
700
|
-
if (!(resume && callback)) {
|
|
701
|
-
_context14.next = 11;
|
|
525
|
+
case 3:
|
|
526
|
+
_context5.next = 0;
|
|
702
527
|
break;
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
var
|
|
708
|
-
return _regeneratorRuntime.wrap(function
|
|
709
|
-
while (1) switch (
|
|
528
|
+
case 5:
|
|
529
|
+
jobSpec = jobSpecs[j];
|
|
530
|
+
files = jobSpec.files; // Upload each item
|
|
531
|
+
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
532
|
+
var fileInfo, retries, succeeded;
|
|
533
|
+
return _regeneratorRuntime.wrap(function _loop$(_context4) {
|
|
534
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
710
535
|
case 0:
|
|
711
|
-
|
|
712
|
-
|
|
536
|
+
fileInfo = files[f];
|
|
537
|
+
retries = 0;
|
|
538
|
+
succeeded = false;
|
|
539
|
+
case 3:
|
|
540
|
+
_context4.prev = 3;
|
|
541
|
+
_context4.next = 6;
|
|
542
|
+
return _this.UploadFileData({
|
|
713
543
|
libraryId: libraryId,
|
|
714
544
|
objectId: objectId,
|
|
715
545
|
writeToken: writeToken,
|
|
716
|
-
uploadId:
|
|
717
|
-
jobId: jobId
|
|
546
|
+
uploadId: id,
|
|
547
|
+
jobId: jobId,
|
|
548
|
+
filePath: fileInfo.path,
|
|
549
|
+
fileData: fileInfo.data,
|
|
550
|
+
encryption: encryption
|
|
718
551
|
});
|
|
719
|
-
case
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
try {
|
|
723
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
724
|
-
_fileInfo = _step2.value;
|
|
725
|
-
// When encrypted, the top-level rem/skip are sentinel (-1) - the real, already-received
|
|
726
|
-
// byte counts for this chunk are under `encrypted` (same lookup UploadFileData uses)
|
|
727
|
-
fileStatus = encryption && encryption !== "none" ? _fileInfo.encrypted : _fileInfo;
|
|
728
|
-
if (fileStatus.rem === 0) {
|
|
729
|
-
alreadyCreditedKeys.add("".concat(jobId, ":").concat(_fileInfo.path));
|
|
730
|
-
progress[_fileInfo.path] = _objectSpread(_objectSpread({}, progress[_fileInfo.path]), {}, {
|
|
731
|
-
uploaded: progress[_fileInfo.path].uploaded + _fileInfo.len
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
} catch (err) {
|
|
736
|
-
_iterator2.e(err);
|
|
737
|
-
} finally {
|
|
738
|
-
_iterator2.f();
|
|
739
|
-
}
|
|
740
|
-
case 5:
|
|
741
|
-
case "end":
|
|
742
|
-
return _context9.stop();
|
|
743
|
-
}
|
|
744
|
-
}, _callee9);
|
|
745
|
-
}));
|
|
746
|
-
return function (_x10) {
|
|
747
|
-
return _ref19.apply(this, arguments);
|
|
748
|
-
};
|
|
749
|
-
}());
|
|
750
|
-
case 10:
|
|
751
|
-
callback(progress);
|
|
752
|
-
case 11:
|
|
753
|
-
// Insert the data to upload into the job spec, encrypting if necessary
|
|
754
|
-
PrepareJobs = /*#__PURE__*/function () {
|
|
755
|
-
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
756
|
-
var j, jobId, job, f, _fileInfo2, data;
|
|
757
|
-
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
758
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
759
|
-
case 0:
|
|
760
|
-
j = 0;
|
|
761
|
-
case 1:
|
|
762
|
-
if (!(j < jobs.length)) {
|
|
763
|
-
_context10.next = 31;
|
|
764
|
-
break;
|
|
765
|
-
}
|
|
766
|
-
case 2:
|
|
767
|
-
if (!(prepared - uploaded > bufferSize)) {
|
|
768
|
-
_context10.next = 7;
|
|
769
|
-
break;
|
|
770
|
-
}
|
|
771
|
-
_context10.next = 5;
|
|
772
|
-
return new Promise(function (resolve) {
|
|
773
|
-
return setTimeout(resolve, 500);
|
|
774
|
-
});
|
|
775
|
-
case 5:
|
|
776
|
-
_context10.next = 2;
|
|
552
|
+
case 6:
|
|
553
|
+
succeeded = true;
|
|
554
|
+
_context4.next = 17;
|
|
777
555
|
break;
|
|
778
|
-
case
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
writeToken: writeToken,
|
|
786
|
-
uploadId: uploadId,
|
|
787
|
-
jobId: jobId
|
|
788
|
-
});
|
|
789
|
-
case 10:
|
|
790
|
-
job = _context10.sent;
|
|
791
|
-
f = 0;
|
|
792
|
-
case 12:
|
|
793
|
-
if (!(f < job.files.length)) {
|
|
794
|
-
_context10.next = 25;
|
|
795
|
-
break;
|
|
796
|
-
}
|
|
797
|
-
_fileInfo2 = job.files[f];
|
|
798
|
-
data = void 0;
|
|
799
|
-
if (typeof fileDataMap[_fileInfo2.path] === "number") {
|
|
800
|
-
// File descriptor - Read data from file
|
|
801
|
-
data = Buffer.alloc(_fileInfo2.len);
|
|
802
|
-
fs.readSync(fileDataMap[_fileInfo2.path], data, 0, _fileInfo2.len, _fileInfo2.off);
|
|
803
|
-
} else {
|
|
804
|
-
// Full data - Slice requested chunk
|
|
805
|
-
data = fileDataMap[_fileInfo2.path].slice(_fileInfo2.off, _fileInfo2.off + _fileInfo2.len);
|
|
806
|
-
}
|
|
807
|
-
if (!(encryption === "cgck")) {
|
|
808
|
-
_context10.next = 20;
|
|
556
|
+
case 9:
|
|
557
|
+
_context4.prev = 9;
|
|
558
|
+
_context4.t0 = _context4["catch"](3);
|
|
559
|
+
_this.Log(_context4.t0, true);
|
|
560
|
+
retries += 1;
|
|
561
|
+
if (!(retries >= 10)) {
|
|
562
|
+
_context4.next = 15;
|
|
809
563
|
break;
|
|
810
564
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
data = _context10.sent;
|
|
815
|
-
case 20:
|
|
816
|
-
job.files[f].data = data;
|
|
817
|
-
prepared += _fileInfo2.len;
|
|
818
|
-
case 22:
|
|
819
|
-
f++;
|
|
820
|
-
_context10.next = 12;
|
|
821
|
-
break;
|
|
822
|
-
case 25:
|
|
823
|
-
jobSpecs[j] = job;
|
|
824
|
-
|
|
825
|
-
// Wait for a bit to let upload start
|
|
826
|
-
_context10.next = 28;
|
|
565
|
+
throw _context4.t0;
|
|
566
|
+
case 15:
|
|
567
|
+
_context4.next = 17;
|
|
827
568
|
return new Promise(function (resolve) {
|
|
828
|
-
return setTimeout(resolve,
|
|
569
|
+
return setTimeout(resolve, 10 * retries * 1000);
|
|
829
570
|
});
|
|
830
|
-
case
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
break;
|
|
834
|
-
case 31:
|
|
835
|
-
case "end":
|
|
836
|
-
return _context10.stop();
|
|
837
|
-
}
|
|
838
|
-
}, _callee10);
|
|
839
|
-
}));
|
|
840
|
-
return function PrepareJobs() {
|
|
841
|
-
return _ref20.apply(this, arguments);
|
|
842
|
-
};
|
|
843
|
-
}();
|
|
844
|
-
UploadJob = /*#__PURE__*/function () {
|
|
845
|
-
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(jobId, j) {
|
|
846
|
-
var jobSpec, files, _loop2, f;
|
|
847
|
-
return _regeneratorRuntime.wrap(function _callee11$(_context12) {
|
|
848
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
849
|
-
case 0:
|
|
850
|
-
if (jobSpecs[j]) {
|
|
851
|
-
_context12.next = 5;
|
|
571
|
+
case 17:
|
|
572
|
+
if (!succeeded && retries < 10) {
|
|
573
|
+
_context4.next = 3;
|
|
852
574
|
break;
|
|
853
575
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
jobSpec = jobSpecs[j];
|
|
863
|
-
files = jobSpec.files; // Upload each item
|
|
864
|
-
_loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2() {
|
|
865
|
-
var fileInfo, retries, succeeded;
|
|
866
|
-
return _regeneratorRuntime.wrap(function _loop2$(_context11) {
|
|
867
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
868
|
-
case 0:
|
|
869
|
-
fileInfo = files[f];
|
|
870
|
-
retries = 0;
|
|
871
|
-
succeeded = false;
|
|
872
|
-
case 3:
|
|
873
|
-
_context11.prev = 3;
|
|
874
|
-
_context11.next = 6;
|
|
875
|
-
return _this2.UploadFileData({
|
|
876
|
-
libraryId: libraryId,
|
|
877
|
-
objectId: objectId,
|
|
878
|
-
writeToken: writeToken,
|
|
879
|
-
uploadId: uploadId,
|
|
880
|
-
jobId: jobId,
|
|
881
|
-
filePath: fileInfo.path,
|
|
882
|
-
fileData: fileInfo.data,
|
|
883
|
-
encryption: encryption
|
|
884
|
-
});
|
|
885
|
-
case 6:
|
|
886
|
-
succeeded = true;
|
|
887
|
-
_context11.next = 17;
|
|
888
|
-
break;
|
|
889
|
-
case 9:
|
|
890
|
-
_context11.prev = 9;
|
|
891
|
-
_context11.t0 = _context11["catch"](3);
|
|
892
|
-
_this2.Log(_context11.t0, true);
|
|
893
|
-
retries += 1;
|
|
894
|
-
if (!(retries >= 10)) {
|
|
895
|
-
_context11.next = 15;
|
|
896
|
-
break;
|
|
897
|
-
}
|
|
898
|
-
throw _context11.t0;
|
|
899
|
-
case 15:
|
|
900
|
-
_context11.next = 17;
|
|
901
|
-
return new Promise(function (resolve) {
|
|
902
|
-
return setTimeout(resolve, 10 * retries * 1000);
|
|
903
|
-
});
|
|
904
|
-
case 17:
|
|
905
|
-
if (!succeeded && retries < 10) {
|
|
906
|
-
_context11.next = 3;
|
|
907
|
-
break;
|
|
908
|
-
}
|
|
909
|
-
case 18:
|
|
910
|
-
delete jobSpecs[j].files[f].data;
|
|
911
|
-
uploaded += fileInfo.len;
|
|
912
|
-
if (callback && !alreadyCreditedKeys.has("".concat(jobId, ":").concat(fileInfo.path))) {
|
|
913
|
-
progress[fileInfo.path] = _objectSpread(_objectSpread({}, progress[fileInfo.path]), {}, {
|
|
914
|
-
uploaded: progress[fileInfo.path].uploaded + fileInfo.len
|
|
915
|
-
});
|
|
916
|
-
callback(progress);
|
|
917
|
-
}
|
|
918
|
-
case 21:
|
|
919
|
-
case "end":
|
|
920
|
-
return _context11.stop();
|
|
921
|
-
}
|
|
922
|
-
}, _loop2, null, [[3, 9]]);
|
|
923
|
-
});
|
|
924
|
-
f = 0;
|
|
925
|
-
case 9:
|
|
926
|
-
if (!(f < files.length)) {
|
|
927
|
-
_context12.next = 14;
|
|
928
|
-
break;
|
|
576
|
+
case 18:
|
|
577
|
+
delete jobSpecs[j].files[f].data;
|
|
578
|
+
uploaded += fileInfo.len;
|
|
579
|
+
if (callback) {
|
|
580
|
+
progress[fileInfo.path] = _objectSpread(_objectSpread({}, progress[fileInfo.path]), {}, {
|
|
581
|
+
uploaded: progress[fileInfo.path].uploaded + fileInfo.len
|
|
582
|
+
});
|
|
583
|
+
callback(progress);
|
|
929
584
|
}
|
|
930
|
-
|
|
931
|
-
case 11:
|
|
932
|
-
f++;
|
|
933
|
-
_context12.next = 9;
|
|
934
|
-
break;
|
|
935
|
-
case 14:
|
|
585
|
+
case 21:
|
|
936
586
|
case "end":
|
|
937
|
-
return
|
|
587
|
+
return _context4.stop();
|
|
938
588
|
}
|
|
939
|
-
},
|
|
940
|
-
})
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
rates = [];
|
|
952
|
-
j = 0;
|
|
953
|
-
case 17:
|
|
954
|
-
if (!(j < rateTestJobs)) {
|
|
955
|
-
_context14.next = 27;
|
|
589
|
+
}, _loop, null, [[3, 9]]);
|
|
590
|
+
});
|
|
591
|
+
f = 0;
|
|
592
|
+
case 9:
|
|
593
|
+
if (!(f < files.length)) {
|
|
594
|
+
_context5.next = 14;
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
return _context5.delegateYield(_loop(), "t0", 11);
|
|
598
|
+
case 11:
|
|
599
|
+
f++;
|
|
600
|
+
_context5.next = 9;
|
|
956
601
|
break;
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
_context14.next = 31;
|
|
979
|
-
return _this2.utils.LimitedMap(concurrentUploads, jobs, /*#__PURE__*/function () {
|
|
980
|
-
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(jobId, j) {
|
|
981
|
-
return _regeneratorRuntime.wrap(function _callee12$(_context13) {
|
|
982
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
983
|
-
case 0:
|
|
984
|
-
if (!(j < rateTestJobs)) {
|
|
985
|
-
_context13.next = 2;
|
|
986
|
-
break;
|
|
987
|
-
}
|
|
988
|
-
return _context13.abrupt("return");
|
|
989
|
-
case 2:
|
|
990
|
-
_context13.prev = 2;
|
|
991
|
-
_context13.next = 5;
|
|
992
|
-
return UploadJob(jobId, j);
|
|
993
|
-
case 5:
|
|
994
|
-
_context13.next = 10;
|
|
995
|
-
break;
|
|
996
|
-
case 7:
|
|
997
|
-
_context13.prev = 7;
|
|
998
|
-
_context13.t0 = _context13["catch"](2);
|
|
999
|
-
throw Error("Failed upload for job ".concat(jobId, ": ").concat(_context13.t0));
|
|
1000
|
-
case 10:
|
|
1001
|
-
case "end":
|
|
1002
|
-
return _context13.stop();
|
|
1003
|
-
}
|
|
1004
|
-
}, _callee12, null, [[2, 7]]);
|
|
1005
|
-
}));
|
|
1006
|
-
return function (_x13, _x14) {
|
|
1007
|
-
return _ref22.apply(this, arguments);
|
|
1008
|
-
};
|
|
1009
|
-
}());
|
|
1010
|
-
case 31:
|
|
1011
|
-
case "end":
|
|
1012
|
-
return _context14.stop();
|
|
1013
|
-
}
|
|
1014
|
-
}, _loop);
|
|
1015
|
-
});
|
|
1016
|
-
_iterator.s();
|
|
1017
|
-
case 54:
|
|
1018
|
-
if ((_step = _iterator.n()).done) {
|
|
1019
|
-
_context15.next = 58;
|
|
602
|
+
case 14:
|
|
603
|
+
case "end":
|
|
604
|
+
return _context5.stop();
|
|
605
|
+
}
|
|
606
|
+
}, _callee4);
|
|
607
|
+
}));
|
|
608
|
+
return function UploadJob(_x4, _x5) {
|
|
609
|
+
return _ref8.apply(this, arguments);
|
|
610
|
+
};
|
|
611
|
+
}(); // Preparing jobs is done asynchronously
|
|
612
|
+
PrepareJobs()["catch"](function (e) {
|
|
613
|
+
throw e;
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
// Upload the first several chunks in sequence, to determine average upload rate
|
|
617
|
+
rateTestJobs = Math.min(3, jobs.length);
|
|
618
|
+
rates = [];
|
|
619
|
+
j = 0;
|
|
620
|
+
case 33:
|
|
621
|
+
if (!(j < rateTestJobs)) {
|
|
622
|
+
_context7.next = 43;
|
|
1020
623
|
break;
|
|
1021
624
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
625
|
+
start = new Date().getTime();
|
|
626
|
+
_context7.next = 37;
|
|
627
|
+
return UploadJob(jobs[j], j);
|
|
628
|
+
case 37:
|
|
629
|
+
elapsed = (new Date().getTime() - start) / 1000;
|
|
630
|
+
size = jobSpecs[j].files.map(function (file) {
|
|
631
|
+
return file.len;
|
|
632
|
+
}).reduce(function (length, total) {
|
|
633
|
+
return length + total;
|
|
634
|
+
}, 0);
|
|
635
|
+
rates.push(size / elapsed / (1024 * 1024));
|
|
636
|
+
case 40:
|
|
637
|
+
j++;
|
|
638
|
+
_context7.next = 33;
|
|
1028
639
|
break;
|
|
1029
|
-
case
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
640
|
+
case 43:
|
|
641
|
+
averageRate = rates.reduce(function (mbps, total) {
|
|
642
|
+
return mbps + total;
|
|
643
|
+
}, 0) / rateTestJobs; // Upload remaining jobs in parallel
|
|
644
|
+
concurrentUploads = Math.min(5, Math.ceil(averageRate / 2));
|
|
645
|
+
_context7.next = 47;
|
|
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 _callee5$(_context6) {
|
|
649
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
650
|
+
case 0:
|
|
651
|
+
if (!(j < rateTestJobs)) {
|
|
652
|
+
_context6.next = 2;
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
return _context6.abrupt("return");
|
|
656
|
+
case 2:
|
|
657
|
+
_context6.next = 4;
|
|
658
|
+
return UploadJob(jobId, j);
|
|
659
|
+
case 4:
|
|
660
|
+
case "end":
|
|
661
|
+
return _context6.stop();
|
|
662
|
+
}
|
|
663
|
+
}, _callee5);
|
|
664
|
+
}));
|
|
665
|
+
return function (_x6, _x7) {
|
|
666
|
+
return _ref9.apply(this, arguments);
|
|
667
|
+
};
|
|
668
|
+
}());
|
|
669
|
+
case 47:
|
|
1038
670
|
case "end":
|
|
1039
|
-
return
|
|
671
|
+
return _context7.stop();
|
|
1040
672
|
}
|
|
1041
|
-
},
|
|
673
|
+
}, _callee6, this);
|
|
1042
674
|
}));
|
|
1043
|
-
return function (
|
|
1044
|
-
return
|
|
675
|
+
return function (_x3) {
|
|
676
|
+
return _ref6.apply(this, arguments);
|
|
1045
677
|
};
|
|
1046
678
|
}();
|
|
1047
679
|
exports.CreateFileUploadJob = /*#__PURE__*/function () {
|
|
1048
|
-
var
|
|
1049
|
-
var libraryId, objectId, writeToken, ops,
|
|
1050
|
-
return _regeneratorRuntime.wrap(function
|
|
1051
|
-
while (1) switch (
|
|
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
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1052
684
|
case 0:
|
|
1053
|
-
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;
|
|
1054
686
|
ValidateParameters({
|
|
1055
687
|
libraryId: libraryId,
|
|
1056
688
|
objectId: objectId
|
|
@@ -1070,8 +702,8 @@ exports.CreateFileUploadJob = /*#__PURE__*/function () {
|
|
|
1070
702
|
ops: ops
|
|
1071
703
|
};
|
|
1072
704
|
path = UrlJoin("q", writeToken, "file_jobs");
|
|
1073
|
-
|
|
1074
|
-
|
|
705
|
+
_context8.t0 = this.HttpClient;
|
|
706
|
+
_context8.next = 11;
|
|
1075
707
|
return this.authClient.AuthorizationHeader({
|
|
1076
708
|
libraryId: libraryId,
|
|
1077
709
|
objectId: objectId,
|
|
@@ -1079,350 +711,169 @@ exports.CreateFileUploadJob = /*#__PURE__*/function () {
|
|
|
1079
711
|
encryption: encryption
|
|
1080
712
|
});
|
|
1081
713
|
case 11:
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
headers:
|
|
714
|
+
_context8.t1 = _context8.sent;
|
|
715
|
+
_context8.t2 = path;
|
|
716
|
+
_context8.t3 = body;
|
|
717
|
+
_context8.t4 = {
|
|
718
|
+
headers: _context8.t1,
|
|
1087
719
|
method: "POST",
|
|
1088
|
-
path:
|
|
1089
|
-
body:
|
|
720
|
+
path: _context8.t2,
|
|
721
|
+
body: _context8.t3,
|
|
1090
722
|
allowFailover: false
|
|
1091
723
|
};
|
|
1092
|
-
return
|
|
724
|
+
return _context8.abrupt("return", _context8.t0.RequestJsonBody.call(_context8.t0, _context8.t4));
|
|
1093
725
|
case 16:
|
|
1094
726
|
case "end":
|
|
1095
|
-
return
|
|
1096
|
-
}
|
|
1097
|
-
}, _callee14, this);
|
|
1098
|
-
}));
|
|
1099
|
-
return function (_x15) {
|
|
1100
|
-
return _ref24.apply(this, arguments);
|
|
1101
|
-
};
|
|
1102
|
-
}();
|
|
1103
|
-
exports.ListFilesJob = /*#__PURE__*/function () {
|
|
1104
|
-
var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref25) {
|
|
1105
|
-
var libraryId, objectId, writeToken, _ref25$encryption, encryption, path;
|
|
1106
|
-
return _regeneratorRuntime.wrap(function _callee15$(_context17) {
|
|
1107
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
1108
|
-
case 0:
|
|
1109
|
-
libraryId = _ref25.libraryId, objectId = _ref25.objectId, writeToken = _ref25.writeToken, _ref25$encryption = _ref25.encryption, encryption = _ref25$encryption === void 0 ? "none" : _ref25$encryption;
|
|
1110
|
-
ValidateParameters({
|
|
1111
|
-
libraryId: libraryId,
|
|
1112
|
-
objectId: objectId
|
|
1113
|
-
});
|
|
1114
|
-
ValidateWriteToken(writeToken);
|
|
1115
|
-
this.Log("List file jobs: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
1116
|
-
path = UrlJoin("q", writeToken, "file_jobs");
|
|
1117
|
-
_context17.t0 = this.HttpClient;
|
|
1118
|
-
_context17.next = 8;
|
|
1119
|
-
return this.authClient.AuthorizationHeader({
|
|
1120
|
-
libraryId: libraryId,
|
|
1121
|
-
objectId: objectId,
|
|
1122
|
-
update: true,
|
|
1123
|
-
encryption: encryption
|
|
1124
|
-
});
|
|
1125
|
-
case 8:
|
|
1126
|
-
_context17.t1 = _context17.sent;
|
|
1127
|
-
_context17.t2 = path;
|
|
1128
|
-
_context17.t3 = {
|
|
1129
|
-
headers: _context17.t1,
|
|
1130
|
-
method: "GET",
|
|
1131
|
-
path: _context17.t2,
|
|
1132
|
-
allowFailover: false
|
|
1133
|
-
};
|
|
1134
|
-
return _context17.abrupt("return", _context17.t0.RequestJsonBody.call(_context17.t0, _context17.t3));
|
|
1135
|
-
case 12:
|
|
1136
|
-
case "end":
|
|
1137
|
-
return _context17.stop();
|
|
1138
|
-
}
|
|
1139
|
-
}, _callee15, this);
|
|
1140
|
-
}));
|
|
1141
|
-
return function (_x16) {
|
|
1142
|
-
return _ref26.apply(this, arguments);
|
|
1143
|
-
};
|
|
1144
|
-
}();
|
|
1145
|
-
exports.ListFilesUploadJobs = /*#__PURE__*/function () {
|
|
1146
|
-
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref27) {
|
|
1147
|
-
var libraryId, objectId, writeToken, jobId, _ref27$encryption, encryption, path;
|
|
1148
|
-
return _regeneratorRuntime.wrap(function _callee16$(_context18) {
|
|
1149
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
1150
|
-
case 0:
|
|
1151
|
-
libraryId = _ref27.libraryId, objectId = _ref27.objectId, writeToken = _ref27.writeToken, jobId = _ref27.jobId, _ref27$encryption = _ref27.encryption, encryption = _ref27$encryption === void 0 ? "none" : _ref27$encryption;
|
|
1152
|
-
ValidateParameters({
|
|
1153
|
-
libraryId: libraryId,
|
|
1154
|
-
objectId: objectId
|
|
1155
|
-
});
|
|
1156
|
-
ValidateWriteToken(writeToken);
|
|
1157
|
-
this.Log("List file upload jobs: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
1158
|
-
path = UrlJoin("qlibs", libraryId, "q", writeToken, "file_jobs", jobId, "uploads");
|
|
1159
|
-
_context18.t0 = this.HttpClient;
|
|
1160
|
-
_context18.next = 8;
|
|
1161
|
-
return this.authClient.AuthorizationHeader({
|
|
1162
|
-
libraryId: libraryId,
|
|
1163
|
-
objectId: objectId,
|
|
1164
|
-
update: true,
|
|
1165
|
-
encryption: encryption
|
|
1166
|
-
});
|
|
1167
|
-
case 8:
|
|
1168
|
-
_context18.t1 = _context18.sent;
|
|
1169
|
-
_context18.t2 = path;
|
|
1170
|
-
_context18.t3 = {
|
|
1171
|
-
headers: _context18.t1,
|
|
1172
|
-
method: "GET",
|
|
1173
|
-
path: _context18.t2,
|
|
1174
|
-
allowFailover: false
|
|
1175
|
-
};
|
|
1176
|
-
return _context18.abrupt("return", _context18.t0.RequestJsonBody.call(_context18.t0, _context18.t3));
|
|
1177
|
-
case 12:
|
|
1178
|
-
case "end":
|
|
1179
|
-
return _context18.stop();
|
|
1180
|
-
}
|
|
1181
|
-
}, _callee16, this);
|
|
1182
|
-
}));
|
|
1183
|
-
return function (_x17) {
|
|
1184
|
-
return _ref28.apply(this, arguments);
|
|
1185
|
-
};
|
|
1186
|
-
}();
|
|
1187
|
-
exports.ResumeFileUploadJob = /*#__PURE__*/function () {
|
|
1188
|
-
var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref29) {
|
|
1189
|
-
var libraryId, objectId, writeToken, ops, _ref29$defaults, defaults, _ref29$encryption, encryption, _ref29$stoppedOrFaile, stoppedOrFailedJobIds, body, responses, _iterator3, _step3, jobId, path, res;
|
|
1190
|
-
return _regeneratorRuntime.wrap(function _callee17$(_context19) {
|
|
1191
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
1192
|
-
case 0:
|
|
1193
|
-
libraryId = _ref29.libraryId, objectId = _ref29.objectId, writeToken = _ref29.writeToken, ops = _ref29.ops, _ref29$defaults = _ref29.defaults, defaults = _ref29$defaults === void 0 ? {} : _ref29$defaults, _ref29$encryption = _ref29.encryption, encryption = _ref29$encryption === void 0 ? "none" : _ref29$encryption, _ref29$stoppedOrFaile = _ref29.stoppedOrFailedJobIds, stoppedOrFailedJobIds = _ref29$stoppedOrFaile === void 0 ? [] : _ref29$stoppedOrFaile;
|
|
1194
|
-
ValidateParameters({
|
|
1195
|
-
libraryId: libraryId,
|
|
1196
|
-
objectId: objectId
|
|
1197
|
-
});
|
|
1198
|
-
ValidateWriteToken(writeToken);
|
|
1199
|
-
if (!(stoppedOrFailedJobIds.length === 0)) {
|
|
1200
|
-
_context19.next = 6;
|
|
1201
|
-
break;
|
|
1202
|
-
}
|
|
1203
|
-
this.Log("No stopped/failed jobs found");
|
|
1204
|
-
throw new Error("No STOPPED/FAILED jobs found");
|
|
1205
|
-
case 6:
|
|
1206
|
-
this.Log("Resuming file upload job: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
1207
|
-
if (encryption === "cgck") {
|
|
1208
|
-
defaults.encryption = {
|
|
1209
|
-
scheme: "cgck"
|
|
1210
|
-
};
|
|
1211
|
-
}
|
|
1212
|
-
body = {
|
|
1213
|
-
seq: 0,
|
|
1214
|
-
seq_complete: true,
|
|
1215
|
-
clear_resolve: true,
|
|
1216
|
-
defaults: defaults,
|
|
1217
|
-
ops: ops
|
|
1218
|
-
}; // resume and change jobId status from 'STOPPED' to 'IN_PROGRESS'
|
|
1219
|
-
responses = [];
|
|
1220
|
-
this.Log("Stopped or Failed job IDs: ".concat(stoppedOrFailedJobIds.join(",")));
|
|
1221
|
-
_iterator3 = _createForOfIteratorHelper(stoppedOrFailedJobIds);
|
|
1222
|
-
_context19.prev = 12;
|
|
1223
|
-
_iterator3.s();
|
|
1224
|
-
case 14:
|
|
1225
|
-
if ((_step3 = _iterator3.n()).done) {
|
|
1226
|
-
_context19.next = 30;
|
|
1227
|
-
break;
|
|
1228
|
-
}
|
|
1229
|
-
jobId = _step3.value;
|
|
1230
|
-
path = UrlJoin("q", writeToken, "file_jobs", jobId, "resume");
|
|
1231
|
-
_context19.t0 = this.HttpClient;
|
|
1232
|
-
_context19.next = 20;
|
|
1233
|
-
return this.authClient.AuthorizationHeader({
|
|
1234
|
-
libraryId: libraryId,
|
|
1235
|
-
objectId: objectId,
|
|
1236
|
-
update: true,
|
|
1237
|
-
encryption: encryption
|
|
1238
|
-
});
|
|
1239
|
-
case 20:
|
|
1240
|
-
_context19.t1 = _context19.sent;
|
|
1241
|
-
_context19.t2 = path;
|
|
1242
|
-
_context19.t3 = body;
|
|
1243
|
-
_context19.t4 = {
|
|
1244
|
-
headers: _context19.t1,
|
|
1245
|
-
method: "PUT",
|
|
1246
|
-
path: _context19.t2,
|
|
1247
|
-
body: _context19.t3,
|
|
1248
|
-
allowFailover: false
|
|
1249
|
-
};
|
|
1250
|
-
_context19.next = 26;
|
|
1251
|
-
return _context19.t0.RequestJsonBody.call(_context19.t0, _context19.t4);
|
|
1252
|
-
case 26:
|
|
1253
|
-
res = _context19.sent;
|
|
1254
|
-
responses.push({
|
|
1255
|
-
message: res,
|
|
1256
|
-
id: jobId
|
|
1257
|
-
});
|
|
1258
|
-
case 28:
|
|
1259
|
-
_context19.next = 14;
|
|
1260
|
-
break;
|
|
1261
|
-
case 30:
|
|
1262
|
-
_context19.next = 35;
|
|
1263
|
-
break;
|
|
1264
|
-
case 32:
|
|
1265
|
-
_context19.prev = 32;
|
|
1266
|
-
_context19.t5 = _context19["catch"](12);
|
|
1267
|
-
_iterator3.e(_context19.t5);
|
|
1268
|
-
case 35:
|
|
1269
|
-
_context19.prev = 35;
|
|
1270
|
-
_iterator3.f();
|
|
1271
|
-
return _context19.finish(35);
|
|
1272
|
-
case 38:
|
|
1273
|
-
return _context19.abrupt("return", responses);
|
|
1274
|
-
case 39:
|
|
1275
|
-
case "end":
|
|
1276
|
-
return _context19.stop();
|
|
727
|
+
return _context8.stop();
|
|
1277
728
|
}
|
|
1278
|
-
},
|
|
729
|
+
}, _callee7, this);
|
|
1279
730
|
}));
|
|
1280
|
-
return function (
|
|
1281
|
-
return
|
|
731
|
+
return function (_x8) {
|
|
732
|
+
return _ref11.apply(this, arguments);
|
|
1282
733
|
};
|
|
1283
734
|
}();
|
|
1284
735
|
exports.UploadStatus = /*#__PURE__*/function () {
|
|
1285
|
-
var
|
|
736
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
1286
737
|
var libraryId, objectId, writeToken, uploadId, path;
|
|
1287
|
-
return _regeneratorRuntime.wrap(function
|
|
1288
|
-
while (1) switch (
|
|
738
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
739
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1289
740
|
case 0:
|
|
1290
|
-
libraryId =
|
|
741
|
+
libraryId = _ref12.libraryId, objectId = _ref12.objectId, writeToken = _ref12.writeToken, uploadId = _ref12.uploadId;
|
|
1291
742
|
ValidateParameters({
|
|
1292
743
|
libraryId: libraryId,
|
|
1293
744
|
objectId: objectId
|
|
1294
745
|
});
|
|
1295
746
|
ValidateWriteToken(writeToken);
|
|
1296
747
|
path = UrlJoin("q", writeToken, "file_jobs", uploadId);
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
748
|
+
_context9.t0 = this.utils;
|
|
749
|
+
_context9.t1 = this.HttpClient;
|
|
750
|
+
_context9.next = 8;
|
|
1300
751
|
return this.authClient.AuthorizationHeader({
|
|
1301
752
|
libraryId: libraryId,
|
|
1302
753
|
objectId: objectId,
|
|
1303
754
|
update: true
|
|
1304
755
|
});
|
|
1305
756
|
case 8:
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
headers:
|
|
757
|
+
_context9.t2 = _context9.sent;
|
|
758
|
+
_context9.t3 = path;
|
|
759
|
+
_context9.t4 = {
|
|
760
|
+
headers: _context9.t2,
|
|
1310
761
|
method: "GET",
|
|
1311
|
-
path:
|
|
762
|
+
path: _context9.t3,
|
|
1312
763
|
allowFailover: false
|
|
1313
764
|
};
|
|
1314
|
-
|
|
1315
|
-
return
|
|
765
|
+
_context9.t5 = _context9.t1.Request.call(_context9.t1, _context9.t4);
|
|
766
|
+
return _context9.abrupt("return", _context9.t0.ResponseToJson.call(_context9.t0, _context9.t5));
|
|
1316
767
|
case 13:
|
|
1317
768
|
case "end":
|
|
1318
|
-
return
|
|
769
|
+
return _context9.stop();
|
|
1319
770
|
}
|
|
1320
|
-
},
|
|
771
|
+
}, _callee8, this);
|
|
1321
772
|
}));
|
|
1322
|
-
return function (
|
|
1323
|
-
return
|
|
773
|
+
return function (_x9) {
|
|
774
|
+
return _ref13.apply(this, arguments);
|
|
1324
775
|
};
|
|
1325
776
|
}();
|
|
1326
777
|
exports.UploadJobStatus = /*#__PURE__*/function () {
|
|
1327
|
-
var
|
|
778
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref14) {
|
|
1328
779
|
var libraryId, objectId, writeToken, uploadId, jobId, path, response, newResponse;
|
|
1329
|
-
return _regeneratorRuntime.wrap(function
|
|
1330
|
-
while (1) switch (
|
|
780
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context10) {
|
|
781
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1331
782
|
case 0:
|
|
1332
|
-
libraryId =
|
|
783
|
+
libraryId = _ref14.libraryId, objectId = _ref14.objectId, writeToken = _ref14.writeToken, uploadId = _ref14.uploadId, jobId = _ref14.jobId;
|
|
1333
784
|
ValidateParameters({
|
|
1334
785
|
libraryId: libraryId,
|
|
1335
786
|
objectId: objectId
|
|
1336
787
|
});
|
|
1337
788
|
ValidateWriteToken(writeToken);
|
|
1338
789
|
path = UrlJoin("q", writeToken, "file_jobs", uploadId, "uploads", jobId);
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
790
|
+
_context10.t0 = this.utils;
|
|
791
|
+
_context10.t1 = this.HttpClient;
|
|
792
|
+
_context10.next = 8;
|
|
1342
793
|
return this.authClient.AuthorizationHeader({
|
|
1343
794
|
libraryId: libraryId,
|
|
1344
795
|
objectId: objectId,
|
|
1345
796
|
update: true
|
|
1346
797
|
});
|
|
1347
798
|
case 8:
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
799
|
+
_context10.t2 = _context10.sent;
|
|
800
|
+
_context10.t3 = path;
|
|
801
|
+
_context10.t4 = {
|
|
1351
802
|
start: 0,
|
|
1352
803
|
limit: 10000
|
|
1353
804
|
};
|
|
1354
|
-
|
|
1355
|
-
headers:
|
|
805
|
+
_context10.t5 = {
|
|
806
|
+
headers: _context10.t2,
|
|
1356
807
|
method: "GET",
|
|
1357
|
-
path:
|
|
808
|
+
path: _context10.t3,
|
|
1358
809
|
allowFailover: false,
|
|
1359
|
-
queryParams:
|
|
810
|
+
queryParams: _context10.t4
|
|
1360
811
|
};
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
return
|
|
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);
|
|
1364
815
|
case 15:
|
|
1365
|
-
response =
|
|
816
|
+
response = _context10.sent;
|
|
1366
817
|
case 16:
|
|
1367
818
|
if (!(response.next !== response.total && response.next >= 0)) {
|
|
1368
|
-
|
|
819
|
+
_context10.next = 33;
|
|
1369
820
|
break;
|
|
1370
821
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
822
|
+
_context10.t7 = this.utils;
|
|
823
|
+
_context10.t8 = this.HttpClient;
|
|
824
|
+
_context10.next = 21;
|
|
1374
825
|
return this.authClient.AuthorizationHeader({
|
|
1375
826
|
libraryId: libraryId,
|
|
1376
827
|
objectId: objectId,
|
|
1377
828
|
update: true
|
|
1378
829
|
});
|
|
1379
830
|
case 21:
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
831
|
+
_context10.t9 = _context10.sent;
|
|
832
|
+
_context10.t10 = path;
|
|
833
|
+
_context10.t11 = {
|
|
1383
834
|
start: response.next
|
|
1384
835
|
};
|
|
1385
|
-
|
|
1386
|
-
headers:
|
|
836
|
+
_context10.t12 = {
|
|
837
|
+
headers: _context10.t9,
|
|
1387
838
|
method: "GET",
|
|
1388
|
-
path:
|
|
839
|
+
path: _context10.t10,
|
|
1389
840
|
allowFailover: false,
|
|
1390
|
-
queryParams:
|
|
841
|
+
queryParams: _context10.t11
|
|
1391
842
|
};
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
return
|
|
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);
|
|
1395
846
|
case 28:
|
|
1396
|
-
newResponse =
|
|
847
|
+
newResponse = _context10.sent;
|
|
1397
848
|
response.files = [].concat(_toConsumableArray(response.files), _toConsumableArray(newResponse.files));
|
|
1398
849
|
response.next = newResponse.next;
|
|
1399
|
-
|
|
850
|
+
_context10.next = 16;
|
|
1400
851
|
break;
|
|
1401
852
|
case 33:
|
|
1402
|
-
return
|
|
853
|
+
return _context10.abrupt("return", response);
|
|
1403
854
|
case 34:
|
|
1404
855
|
case "end":
|
|
1405
|
-
return
|
|
856
|
+
return _context10.stop();
|
|
1406
857
|
}
|
|
1407
|
-
},
|
|
858
|
+
}, _callee9, this);
|
|
1408
859
|
}));
|
|
1409
|
-
return function (
|
|
1410
|
-
return
|
|
860
|
+
return function (_x10) {
|
|
861
|
+
return _ref15.apply(this, arguments);
|
|
1411
862
|
};
|
|
1412
863
|
}();
|
|
1413
864
|
exports.UploadFileData = /*#__PURE__*/function () {
|
|
1414
|
-
var
|
|
1415
|
-
var libraryId, objectId, writeToken, encryption, uploadId, jobId, filePath, fileData, jobStatus, fileStatus, path
|
|
1416
|
-
return _regeneratorRuntime.wrap(function
|
|
1417
|
-
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) {
|
|
1418
869
|
case 0:
|
|
1419
|
-
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;
|
|
1420
871
|
ValidateParameters({
|
|
1421
872
|
libraryId: libraryId,
|
|
1422
873
|
objectId: objectId
|
|
1423
874
|
});
|
|
1424
875
|
ValidateWriteToken(writeToken);
|
|
1425
|
-
|
|
876
|
+
_context11.next = 5;
|
|
1426
877
|
return this.UploadJobStatus({
|
|
1427
878
|
libraryId: libraryId,
|
|
1428
879
|
objectId: objectId,
|
|
@@ -1431,7 +882,7 @@ exports.UploadFileData = /*#__PURE__*/function () {
|
|
|
1431
882
|
jobId: jobId
|
|
1432
883
|
});
|
|
1433
884
|
case 5:
|
|
1434
|
-
jobStatus =
|
|
885
|
+
jobStatus = _context11.sent;
|
|
1435
886
|
// Find the status of this file
|
|
1436
887
|
fileStatus = jobStatus.files.find(function (item) {
|
|
1437
888
|
return item.path === filePath;
|
|
@@ -1440,71 +891,64 @@ exports.UploadFileData = /*#__PURE__*/function () {
|
|
|
1440
891
|
fileStatus = fileStatus.encrypted;
|
|
1441
892
|
}
|
|
1442
893
|
if (!(fileStatus.rem === 0)) {
|
|
1443
|
-
|
|
894
|
+
_context11.next = 12;
|
|
1444
895
|
break;
|
|
1445
896
|
}
|
|
1446
|
-
return
|
|
897
|
+
return _context11.abrupt("return");
|
|
1447
898
|
case 12:
|
|
1448
899
|
if (fileStatus.skip) {
|
|
1449
900
|
fileData = fileData.slice(fileStatus.skip);
|
|
1450
901
|
}
|
|
1451
902
|
case 13:
|
|
1452
903
|
path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
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 = {
|
|
1459
910
|
"Content-type": "application/octet-stream"
|
|
1460
911
|
};
|
|
1461
|
-
|
|
912
|
+
_context11.next = 22;
|
|
1462
913
|
return this.authClient.AuthorizationHeader({
|
|
1463
914
|
libraryId: libraryId,
|
|
1464
915
|
objectId: objectId,
|
|
1465
916
|
update: true
|
|
1466
917
|
});
|
|
1467
918
|
case 22:
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
919
|
+
_context11.t6 = _context11.sent;
|
|
920
|
+
_context11.t7 = (0, _context11.t4)(_context11.t5, _context11.t6);
|
|
921
|
+
_context11.t8 = {
|
|
1471
922
|
method: "POST",
|
|
1472
|
-
path:
|
|
1473
|
-
body:
|
|
923
|
+
path: _context11.t2,
|
|
924
|
+
body: _context11.t3,
|
|
1474
925
|
bodyType: "BINARY",
|
|
1475
|
-
headers:
|
|
926
|
+
headers: _context11.t7,
|
|
1476
927
|
allowFailover: false,
|
|
1477
928
|
allowRetry: false
|
|
1478
929
|
};
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
return
|
|
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);
|
|
1482
933
|
case 28:
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
_context22.next = 31;
|
|
1486
|
-
break;
|
|
1487
|
-
}
|
|
1488
|
-
throw new Error("Upload did not finalize part for ".concat(filePath, " (job ").concat(jobId, ")"));
|
|
1489
|
-
case 31:
|
|
1490
|
-
return _context22.abrupt("return", response);
|
|
1491
|
-
case 32:
|
|
934
|
+
return _context11.abrupt("return", _context11.sent);
|
|
935
|
+
case 29:
|
|
1492
936
|
case "end":
|
|
1493
|
-
return
|
|
937
|
+
return _context11.stop();
|
|
1494
938
|
}
|
|
1495
|
-
},
|
|
939
|
+
}, _callee10, this);
|
|
1496
940
|
}));
|
|
1497
|
-
return function (
|
|
1498
|
-
return
|
|
941
|
+
return function (_x11) {
|
|
942
|
+
return _ref17.apply(this, arguments);
|
|
1499
943
|
};
|
|
1500
944
|
}();
|
|
1501
945
|
exports.FinalizeUploadJob = /*#__PURE__*/function () {
|
|
1502
|
-
var
|
|
946
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref18) {
|
|
1503
947
|
var libraryId, objectId, writeToken, path;
|
|
1504
|
-
return _regeneratorRuntime.wrap(function
|
|
1505
|
-
while (1) switch (
|
|
948
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context12) {
|
|
949
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1506
950
|
case 0:
|
|
1507
|
-
libraryId =
|
|
951
|
+
libraryId = _ref18.libraryId, objectId = _ref18.objectId, writeToken = _ref18.writeToken;
|
|
1508
952
|
ValidateParameters({
|
|
1509
953
|
libraryId: libraryId,
|
|
1510
954
|
objectId: objectId
|
|
@@ -1512,33 +956,33 @@ exports.FinalizeUploadJob = /*#__PURE__*/function () {
|
|
|
1512
956
|
ValidateWriteToken(writeToken);
|
|
1513
957
|
this.Log("Finalizing upload job: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
1514
958
|
path = UrlJoin("q", writeToken, "files");
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
959
|
+
_context12.t0 = this.HttpClient;
|
|
960
|
+
_context12.t1 = path;
|
|
961
|
+
_context12.next = 9;
|
|
1518
962
|
return this.authClient.AuthorizationHeader({
|
|
1519
963
|
libraryId: libraryId,
|
|
1520
964
|
objectId: objectId,
|
|
1521
965
|
update: true
|
|
1522
966
|
});
|
|
1523
967
|
case 9:
|
|
1524
|
-
|
|
1525
|
-
|
|
968
|
+
_context12.t2 = _context12.sent;
|
|
969
|
+
_context12.t3 = {
|
|
1526
970
|
method: "POST",
|
|
1527
|
-
path:
|
|
971
|
+
path: _context12.t1,
|
|
1528
972
|
bodyType: "BINARY",
|
|
1529
|
-
headers:
|
|
973
|
+
headers: _context12.t2,
|
|
1530
974
|
allowFailover: false
|
|
1531
975
|
};
|
|
1532
|
-
|
|
1533
|
-
return
|
|
976
|
+
_context12.next = 13;
|
|
977
|
+
return _context12.t0.Request.call(_context12.t0, _context12.t3);
|
|
1534
978
|
case 13:
|
|
1535
979
|
case "end":
|
|
1536
|
-
return
|
|
980
|
+
return _context12.stop();
|
|
1537
981
|
}
|
|
1538
|
-
},
|
|
982
|
+
}, _callee11, this);
|
|
1539
983
|
}));
|
|
1540
|
-
return function (
|
|
1541
|
-
return
|
|
984
|
+
return function (_x12) {
|
|
985
|
+
return _ref19.apply(this, arguments);
|
|
1542
986
|
};
|
|
1543
987
|
}();
|
|
1544
988
|
|
|
@@ -1554,12 +998,12 @@ exports.FinalizeUploadJob = /*#__PURE__*/function () {
|
|
|
1554
998
|
* @param {Array<string>} filePaths - List of file paths to create
|
|
1555
999
|
*/
|
|
1556
1000
|
exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
1557
|
-
var
|
|
1001
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref20) {
|
|
1558
1002
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1559
|
-
return _regeneratorRuntime.wrap(function
|
|
1560
|
-
while (1) switch (
|
|
1003
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context13) {
|
|
1004
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1561
1005
|
case 0:
|
|
1562
|
-
libraryId =
|
|
1006
|
+
libraryId = _ref20.libraryId, objectId = _ref20.objectId, writeToken = _ref20.writeToken, filePaths = _ref20.filePaths;
|
|
1563
1007
|
ValidateParameters({
|
|
1564
1008
|
libraryId: libraryId,
|
|
1565
1009
|
objectId: objectId
|
|
@@ -1574,7 +1018,7 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
|
1574
1018
|
path: path
|
|
1575
1019
|
};
|
|
1576
1020
|
});
|
|
1577
|
-
|
|
1021
|
+
_context13.next = 8;
|
|
1578
1022
|
return this.CreateFileUploadJob({
|
|
1579
1023
|
libraryId: libraryId,
|
|
1580
1024
|
objectId: objectId,
|
|
@@ -1583,12 +1027,12 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
|
1583
1027
|
});
|
|
1584
1028
|
case 8:
|
|
1585
1029
|
case "end":
|
|
1586
|
-
return
|
|
1030
|
+
return _context13.stop();
|
|
1587
1031
|
}
|
|
1588
|
-
},
|
|
1032
|
+
}, _callee12, this);
|
|
1589
1033
|
}));
|
|
1590
|
-
return function (
|
|
1591
|
-
return
|
|
1034
|
+
return function (_x13) {
|
|
1035
|
+
return _ref21.apply(this, arguments);
|
|
1592
1036
|
};
|
|
1593
1037
|
}();
|
|
1594
1038
|
|
|
@@ -1604,12 +1048,12 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
|
1604
1048
|
* @param {Array<string>} filePaths - List of file paths to move. Format: ```[ { "path": "original/path", to: "new/path" } ]```
|
|
1605
1049
|
*/
|
|
1606
1050
|
exports.MoveFiles = /*#__PURE__*/function () {
|
|
1607
|
-
var
|
|
1051
|
+
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref22) {
|
|
1608
1052
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1609
|
-
return _regeneratorRuntime.wrap(function
|
|
1610
|
-
while (1) switch (
|
|
1053
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context14) {
|
|
1054
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1611
1055
|
case 0:
|
|
1612
|
-
libraryId =
|
|
1056
|
+
libraryId = _ref22.libraryId, objectId = _ref22.objectId, writeToken = _ref22.writeToken, filePaths = _ref22.filePaths;
|
|
1613
1057
|
ValidateParameters({
|
|
1614
1058
|
libraryId: libraryId,
|
|
1615
1059
|
objectId: objectId
|
|
@@ -1617,16 +1061,16 @@ exports.MoveFiles = /*#__PURE__*/function () {
|
|
|
1617
1061
|
ValidateWriteToken(writeToken);
|
|
1618
1062
|
this.Log("Moving Files: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
1619
1063
|
this.Log(filePaths);
|
|
1620
|
-
ops = filePaths.map(function (
|
|
1621
|
-
var path =
|
|
1622
|
-
to =
|
|
1064
|
+
ops = filePaths.map(function (_ref24) {
|
|
1065
|
+
var path = _ref24.path,
|
|
1066
|
+
to = _ref24.to;
|
|
1623
1067
|
return {
|
|
1624
1068
|
op: "move",
|
|
1625
1069
|
copy_move_source_path: path,
|
|
1626
1070
|
path: to
|
|
1627
1071
|
};
|
|
1628
1072
|
});
|
|
1629
|
-
|
|
1073
|
+
_context14.next = 8;
|
|
1630
1074
|
return this.CreateFileUploadJob({
|
|
1631
1075
|
libraryId: libraryId,
|
|
1632
1076
|
objectId: objectId,
|
|
@@ -1635,12 +1079,12 @@ exports.MoveFiles = /*#__PURE__*/function () {
|
|
|
1635
1079
|
});
|
|
1636
1080
|
case 8:
|
|
1637
1081
|
case "end":
|
|
1638
|
-
return
|
|
1082
|
+
return _context14.stop();
|
|
1639
1083
|
}
|
|
1640
|
-
},
|
|
1084
|
+
}, _callee13, this);
|
|
1641
1085
|
}));
|
|
1642
|
-
return function (
|
|
1643
|
-
return
|
|
1086
|
+
return function (_x14) {
|
|
1087
|
+
return _ref23.apply(this, arguments);
|
|
1644
1088
|
};
|
|
1645
1089
|
}();
|
|
1646
1090
|
|
|
@@ -1656,12 +1100,12 @@ exports.MoveFiles = /*#__PURE__*/function () {
|
|
|
1656
1100
|
* @param {Array<string>} filePaths - List of file paths to delete
|
|
1657
1101
|
*/
|
|
1658
1102
|
exports.DeleteFiles = /*#__PURE__*/function () {
|
|
1659
|
-
var
|
|
1103
|
+
var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref25) {
|
|
1660
1104
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1661
|
-
return _regeneratorRuntime.wrap(function
|
|
1662
|
-
while (1) switch (
|
|
1105
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context15) {
|
|
1106
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1663
1107
|
case 0:
|
|
1664
|
-
libraryId =
|
|
1108
|
+
libraryId = _ref25.libraryId, objectId = _ref25.objectId, writeToken = _ref25.writeToken, filePaths = _ref25.filePaths;
|
|
1665
1109
|
ValidateParameters({
|
|
1666
1110
|
libraryId: libraryId,
|
|
1667
1111
|
objectId: objectId
|
|
@@ -1675,7 +1119,7 @@ exports.DeleteFiles = /*#__PURE__*/function () {
|
|
|
1675
1119
|
path: path
|
|
1676
1120
|
};
|
|
1677
1121
|
});
|
|
1678
|
-
|
|
1122
|
+
_context15.next = 8;
|
|
1679
1123
|
return this.CreateFileUploadJob({
|
|
1680
1124
|
libraryId: libraryId,
|
|
1681
1125
|
objectId: objectId,
|
|
@@ -1684,12 +1128,12 @@ exports.DeleteFiles = /*#__PURE__*/function () {
|
|
|
1684
1128
|
});
|
|
1685
1129
|
case 8:
|
|
1686
1130
|
case "end":
|
|
1687
|
-
return
|
|
1131
|
+
return _context15.stop();
|
|
1688
1132
|
}
|
|
1689
|
-
},
|
|
1133
|
+
}, _callee14, this);
|
|
1690
1134
|
}));
|
|
1691
|
-
return function (
|
|
1692
|
-
return
|
|
1135
|
+
return function (_x15) {
|
|
1136
|
+
return _ref26.apply(this, arguments);
|
|
1693
1137
|
};
|
|
1694
1138
|
}();
|
|
1695
1139
|
|
|
@@ -1718,18 +1162,18 @@ exports.DeleteFiles = /*#__PURE__*/function () {
|
|
|
1718
1162
|
* @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, file data in the requested format otherwise
|
|
1719
1163
|
*/
|
|
1720
1164
|
exports.DownloadFile = /*#__PURE__*/function () {
|
|
1721
|
-
var
|
|
1165
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref27) {
|
|
1722
1166
|
var libraryId,
|
|
1723
1167
|
objectId,
|
|
1724
1168
|
versionHash,
|
|
1725
1169
|
writeToken,
|
|
1726
1170
|
filePath,
|
|
1727
|
-
|
|
1171
|
+
_ref27$format,
|
|
1728
1172
|
format,
|
|
1729
|
-
|
|
1173
|
+
_ref27$chunked,
|
|
1730
1174
|
chunked,
|
|
1731
1175
|
chunkSize,
|
|
1732
|
-
|
|
1176
|
+
_ref27$clientSideDecr,
|
|
1733
1177
|
clientSideDecryption,
|
|
1734
1178
|
callback,
|
|
1735
1179
|
fileInfo,
|
|
@@ -1740,11 +1184,11 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1740
1184
|
ownerCapKey,
|
|
1741
1185
|
ownerCap,
|
|
1742
1186
|
bytesTotal,
|
|
1743
|
-
|
|
1744
|
-
return _regeneratorRuntime.wrap(function
|
|
1745
|
-
while (1) switch (
|
|
1187
|
+
_args16 = arguments;
|
|
1188
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context16) {
|
|
1189
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1746
1190
|
case 0:
|
|
1747
|
-
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;
|
|
1748
1192
|
ValidateParameters({
|
|
1749
1193
|
libraryId: libraryId,
|
|
1750
1194
|
objectId: objectId,
|
|
@@ -1754,7 +1198,7 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1754
1198
|
if (versionHash) {
|
|
1755
1199
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1756
1200
|
}
|
|
1757
|
-
|
|
1201
|
+
_context16.next = 6;
|
|
1758
1202
|
return this.ContentObjectMetadata({
|
|
1759
1203
|
libraryId: libraryId,
|
|
1760
1204
|
objectId: objectId,
|
|
@@ -1763,11 +1207,11 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1763
1207
|
metadataSubtree: UrlJoin("files", filePath)
|
|
1764
1208
|
});
|
|
1765
1209
|
case 6:
|
|
1766
|
-
fileInfo =
|
|
1210
|
+
fileInfo = _context16.sent;
|
|
1767
1211
|
encrypted = fileInfo && fileInfo["."].encryption && fileInfo["."].encryption.scheme === "cgck";
|
|
1768
1212
|
encryption = encrypted ? "cgck" : undefined;
|
|
1769
1213
|
path = encrypted && !clientSideDecryption ? UrlJoin("q", writeToken || versionHash || objectId, "rep", "files_download", filePath) : UrlJoin("q", writeToken || versionHash || objectId, "files", filePath);
|
|
1770
|
-
|
|
1214
|
+
_context16.next = 12;
|
|
1771
1215
|
return this.authClient.AuthorizationHeader({
|
|
1772
1216
|
libraryId: libraryId,
|
|
1773
1217
|
objectId: objectId,
|
|
@@ -1776,12 +1220,12 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1776
1220
|
makeAccessRequest: encryption === "cgck"
|
|
1777
1221
|
});
|
|
1778
1222
|
case 12:
|
|
1779
|
-
headers =
|
|
1223
|
+
headers = _context16.sent;
|
|
1780
1224
|
headers.Accept = "*/*";
|
|
1781
1225
|
|
|
1782
1226
|
// If not owner, indicate re-encryption
|
|
1783
1227
|
ownerCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
|
|
1784
|
-
|
|
1228
|
+
_context16.next = 17;
|
|
1785
1229
|
return this.ContentObjectMetadata({
|
|
1786
1230
|
libraryId: libraryId,
|
|
1787
1231
|
objectId: objectId,
|
|
@@ -1789,31 +1233,31 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1789
1233
|
metadataSubtree: ownerCapKey
|
|
1790
1234
|
});
|
|
1791
1235
|
case 17:
|
|
1792
|
-
ownerCap =
|
|
1793
|
-
|
|
1794
|
-
if (!
|
|
1795
|
-
|
|
1236
|
+
ownerCap = _context16.sent;
|
|
1237
|
+
_context16.t1 = encrypted;
|
|
1238
|
+
if (!_context16.t1) {
|
|
1239
|
+
_context16.next = 26;
|
|
1796
1240
|
break;
|
|
1797
1241
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1242
|
+
_context16.t2 = this.utils;
|
|
1243
|
+
_context16.t3 = this.signer.address;
|
|
1244
|
+
_context16.next = 24;
|
|
1801
1245
|
return this.ContentObjectOwner({
|
|
1802
1246
|
objectId: objectId
|
|
1803
1247
|
});
|
|
1804
1248
|
case 24:
|
|
1805
|
-
|
|
1806
|
-
|
|
1249
|
+
_context16.t4 = _context16.sent;
|
|
1250
|
+
_context16.t1 = !_context16.t2.EqualAddress.call(_context16.t2, _context16.t3, _context16.t4);
|
|
1807
1251
|
case 26:
|
|
1808
|
-
|
|
1809
|
-
if (!
|
|
1810
|
-
|
|
1252
|
+
_context16.t0 = _context16.t1;
|
|
1253
|
+
if (!_context16.t0) {
|
|
1254
|
+
_context16.next = 29;
|
|
1811
1255
|
break;
|
|
1812
1256
|
}
|
|
1813
|
-
|
|
1257
|
+
_context16.t0 = !ownerCap;
|
|
1814
1258
|
case 29:
|
|
1815
|
-
if (!
|
|
1816
|
-
|
|
1259
|
+
if (!_context16.t0) {
|
|
1260
|
+
_context16.next = 31;
|
|
1817
1261
|
break;
|
|
1818
1262
|
}
|
|
1819
1263
|
headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
|
|
@@ -1826,11 +1270,11 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1826
1270
|
}
|
|
1827
1271
|
bytesTotal = fileInfo["."].size;
|
|
1828
1272
|
if (!(encrypted && clientSideDecryption)) {
|
|
1829
|
-
|
|
1273
|
+
_context16.next = 51;
|
|
1830
1274
|
break;
|
|
1831
1275
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1276
|
+
_context16.t5 = this;
|
|
1277
|
+
_context16.next = 37;
|
|
1834
1278
|
return this.EncryptionConk({
|
|
1835
1279
|
libraryId: libraryId,
|
|
1836
1280
|
objectId: objectId,
|
|
@@ -1838,34 +1282,34 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1838
1282
|
download: true
|
|
1839
1283
|
});
|
|
1840
1284
|
case 37:
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
conk:
|
|
1851
|
-
downloadPath:
|
|
1852
|
-
bytesTotal:
|
|
1853
|
-
headers:
|
|
1854
|
-
callback:
|
|
1855
|
-
format:
|
|
1856
|
-
clientSideDecryption:
|
|
1857
|
-
chunked:
|
|
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
|
|
1858
1302
|
};
|
|
1859
|
-
|
|
1860
|
-
return
|
|
1303
|
+
_context16.next = 48;
|
|
1304
|
+
return _context16.t5.DownloadEncrypted.call(_context16.t5, _context16.t14);
|
|
1861
1305
|
case 48:
|
|
1862
|
-
return
|
|
1306
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1863
1307
|
case 51:
|
|
1864
1308
|
if (!chunkSize) {
|
|
1865
1309
|
chunkSize = 10000000;
|
|
1866
1310
|
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1311
|
+
_context16.prev = 52;
|
|
1312
|
+
_context16.next = 55;
|
|
1869
1313
|
return this.Download({
|
|
1870
1314
|
downloadPath: path,
|
|
1871
1315
|
bytesTotal: bytesTotal,
|
|
@@ -1876,27 +1320,27 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1876
1320
|
chunkSize: chunkSize
|
|
1877
1321
|
});
|
|
1878
1322
|
case 55:
|
|
1879
|
-
return
|
|
1323
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1880
1324
|
case 58:
|
|
1881
|
-
|
|
1882
|
-
|
|
1325
|
+
_context16.prev = 58;
|
|
1326
|
+
_context16.t15 = _context16["catch"](52);
|
|
1883
1327
|
if (!(encrypted && !clientSideDecryption)) {
|
|
1884
|
-
|
|
1328
|
+
_context16.next = 62;
|
|
1885
1329
|
break;
|
|
1886
1330
|
}
|
|
1887
|
-
return
|
|
1331
|
+
return _context16.abrupt("return", this.DownloadFile(_objectSpread(_objectSpread({}, _args16[0]), {}, {
|
|
1888
1332
|
clientSideDecryption: true
|
|
1889
1333
|
})));
|
|
1890
1334
|
case 62:
|
|
1891
|
-
throw
|
|
1335
|
+
throw _context16.t15;
|
|
1892
1336
|
case 63:
|
|
1893
1337
|
case "end":
|
|
1894
|
-
return
|
|
1338
|
+
return _context16.stop();
|
|
1895
1339
|
}
|
|
1896
|
-
},
|
|
1340
|
+
}, _callee15, this, [[52, 58]]);
|
|
1897
1341
|
}));
|
|
1898
|
-
return function (
|
|
1899
|
-
return
|
|
1342
|
+
return function (_x16) {
|
|
1343
|
+
return _ref28.apply(this, arguments);
|
|
1900
1344
|
};
|
|
1901
1345
|
}();
|
|
1902
1346
|
|
|
@@ -1915,12 +1359,12 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1915
1359
|
* @returns {Promise<Object>} - Response containing list of parts of the object
|
|
1916
1360
|
*/
|
|
1917
1361
|
exports.ContentParts = /*#__PURE__*/function () {
|
|
1918
|
-
var
|
|
1362
|
+
var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref29) {
|
|
1919
1363
|
var libraryId, objectId, versionHash, path, response;
|
|
1920
|
-
return _regeneratorRuntime.wrap(function
|
|
1921
|
-
while (1) switch (
|
|
1364
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context17) {
|
|
1365
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1922
1366
|
case 0:
|
|
1923
|
-
libraryId =
|
|
1367
|
+
libraryId = _ref29.libraryId, objectId = _ref29.objectId, versionHash = _ref29.versionHash;
|
|
1924
1368
|
ValidateParameters({
|
|
1925
1369
|
libraryId: libraryId,
|
|
1926
1370
|
objectId: objectId,
|
|
@@ -1931,34 +1375,34 @@ exports.ContentParts = /*#__PURE__*/function () {
|
|
|
1931
1375
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1932
1376
|
}
|
|
1933
1377
|
path = UrlJoin("q", versionHash || objectId, "parts");
|
|
1934
|
-
|
|
1935
|
-
|
|
1378
|
+
_context17.t0 = this.HttpClient;
|
|
1379
|
+
_context17.next = 8;
|
|
1936
1380
|
return this.authClient.AuthorizationHeader({
|
|
1937
1381
|
libraryId: libraryId,
|
|
1938
1382
|
objectId: objectId,
|
|
1939
1383
|
versionHash: versionHash
|
|
1940
1384
|
});
|
|
1941
1385
|
case 8:
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
headers:
|
|
1386
|
+
_context17.t1 = _context17.sent;
|
|
1387
|
+
_context17.t2 = path;
|
|
1388
|
+
_context17.t3 = {
|
|
1389
|
+
headers: _context17.t1,
|
|
1946
1390
|
method: "GET",
|
|
1947
|
-
path:
|
|
1391
|
+
path: _context17.t2
|
|
1948
1392
|
};
|
|
1949
|
-
|
|
1950
|
-
return
|
|
1393
|
+
_context17.next = 13;
|
|
1394
|
+
return _context17.t0.RequestJsonBody.call(_context17.t0, _context17.t3);
|
|
1951
1395
|
case 13:
|
|
1952
|
-
response =
|
|
1953
|
-
return
|
|
1396
|
+
response = _context17.sent;
|
|
1397
|
+
return _context17.abrupt("return", response.parts);
|
|
1954
1398
|
case 15:
|
|
1955
1399
|
case "end":
|
|
1956
|
-
return
|
|
1400
|
+
return _context17.stop();
|
|
1957
1401
|
}
|
|
1958
|
-
},
|
|
1402
|
+
}, _callee16, this);
|
|
1959
1403
|
}));
|
|
1960
|
-
return function (
|
|
1961
|
-
return
|
|
1404
|
+
return function (_x17) {
|
|
1405
|
+
return _ref30.apply(this, arguments);
|
|
1962
1406
|
};
|
|
1963
1407
|
}();
|
|
1964
1408
|
|
|
@@ -1976,12 +1420,12 @@ exports.ContentParts = /*#__PURE__*/function () {
|
|
|
1976
1420
|
* @returns {Promise<Object>} - Response containing information about the specified part
|
|
1977
1421
|
*/
|
|
1978
1422
|
exports.ContentPart = /*#__PURE__*/function () {
|
|
1979
|
-
var
|
|
1423
|
+
var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref31) {
|
|
1980
1424
|
var libraryId, objectId, versionHash, partHash, path;
|
|
1981
|
-
return _regeneratorRuntime.wrap(function
|
|
1982
|
-
while (1) switch (
|
|
1425
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context18) {
|
|
1426
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1983
1427
|
case 0:
|
|
1984
|
-
libraryId =
|
|
1428
|
+
libraryId = _ref31.libraryId, objectId = _ref31.objectId, versionHash = _ref31.versionHash, partHash = _ref31.partHash;
|
|
1985
1429
|
ValidateParameters({
|
|
1986
1430
|
libraryId: libraryId,
|
|
1987
1431
|
objectId: objectId,
|
|
@@ -1993,33 +1437,33 @@ exports.ContentPart = /*#__PURE__*/function () {
|
|
|
1993
1437
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1994
1438
|
}
|
|
1995
1439
|
path = UrlJoin("q", versionHash || objectId, "parts", partHash);
|
|
1996
|
-
|
|
1997
|
-
|
|
1440
|
+
_context18.t0 = this.HttpClient;
|
|
1441
|
+
_context18.next = 9;
|
|
1998
1442
|
return this.authClient.AuthorizationHeader({
|
|
1999
1443
|
libraryId: libraryId,
|
|
2000
1444
|
objectId: objectId,
|
|
2001
1445
|
versionHash: versionHash
|
|
2002
1446
|
});
|
|
2003
1447
|
case 9:
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
headers:
|
|
1448
|
+
_context18.t1 = _context18.sent;
|
|
1449
|
+
_context18.t2 = path;
|
|
1450
|
+
_context18.t3 = {
|
|
1451
|
+
headers: _context18.t1,
|
|
2008
1452
|
method: "GET",
|
|
2009
|
-
path:
|
|
1453
|
+
path: _context18.t2
|
|
2010
1454
|
};
|
|
2011
|
-
|
|
2012
|
-
return
|
|
1455
|
+
_context18.next = 14;
|
|
1456
|
+
return _context18.t0.RequestJsonBody.call(_context18.t0, _context18.t3);
|
|
2013
1457
|
case 14:
|
|
2014
|
-
return
|
|
1458
|
+
return _context18.abrupt("return", _context18.sent);
|
|
2015
1459
|
case 15:
|
|
2016
1460
|
case "end":
|
|
2017
|
-
return
|
|
1461
|
+
return _context18.stop();
|
|
2018
1462
|
}
|
|
2019
|
-
},
|
|
1463
|
+
}, _callee17, this);
|
|
2020
1464
|
}));
|
|
2021
|
-
return function (
|
|
2022
|
-
return
|
|
1465
|
+
return function (_x18) {
|
|
1466
|
+
return _ref32.apply(this, arguments);
|
|
2023
1467
|
};
|
|
2024
1468
|
}();
|
|
2025
1469
|
|
|
@@ -2048,12 +1492,12 @@ exports.ContentPart = /*#__PURE__*/function () {
|
|
|
2048
1492
|
* @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, part data in the requested format otherwise
|
|
2049
1493
|
*/
|
|
2050
1494
|
exports.DownloadPart = /*#__PURE__*/function () {
|
|
2051
|
-
var
|
|
2052
|
-
var libraryId, objectId, versionHash, writeToken, partHash,
|
|
2053
|
-
return _regeneratorRuntime.wrap(function
|
|
2054
|
-
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) {
|
|
2055
1499
|
case 0:
|
|
2056
|
-
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;
|
|
2057
1501
|
ValidateParameters({
|
|
2058
1502
|
libraryId: libraryId,
|
|
2059
1503
|
objectId: objectId,
|
|
@@ -2066,7 +1510,7 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
2066
1510
|
encrypted = partHash.startsWith("hqpe");
|
|
2067
1511
|
encryption = encrypted ? "cgck" : undefined;
|
|
2068
1512
|
path = UrlJoin("q", writeToken || versionHash || objectId, "data", partHash);
|
|
2069
|
-
|
|
1513
|
+
_context19.next = 9;
|
|
2070
1514
|
return this.authClient.AuthorizationHeader({
|
|
2071
1515
|
libraryId: libraryId,
|
|
2072
1516
|
objectId: objectId,
|
|
@@ -2075,8 +1519,8 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
2075
1519
|
makeAccessRequest: true
|
|
2076
1520
|
});
|
|
2077
1521
|
case 9:
|
|
2078
|
-
headers =
|
|
2079
|
-
|
|
1522
|
+
headers = _context19.sent;
|
|
1523
|
+
_context19.next = 12;
|
|
2080
1524
|
return this.ContentPart({
|
|
2081
1525
|
libraryId: libraryId,
|
|
2082
1526
|
objectId: objectId,
|
|
@@ -2084,55 +1528,55 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
2084
1528
|
partHash: partHash
|
|
2085
1529
|
});
|
|
2086
1530
|
case 12:
|
|
2087
|
-
bytesTotal =
|
|
1531
|
+
bytesTotal = _context19.sent.part.size;
|
|
2088
1532
|
if (!encrypted) {
|
|
2089
|
-
|
|
1533
|
+
_context19.next = 37;
|
|
2090
1534
|
break;
|
|
2091
1535
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
1536
|
+
_context19.t0 = this.utils;
|
|
1537
|
+
_context19.t1 = this.signer.address;
|
|
1538
|
+
_context19.next = 18;
|
|
2095
1539
|
return this.ContentObjectOwner({
|
|
2096
1540
|
objectId: objectId
|
|
2097
1541
|
});
|
|
2098
1542
|
case 18:
|
|
2099
|
-
|
|
2100
|
-
if (
|
|
2101
|
-
|
|
1543
|
+
_context19.t2 = _context19.sent;
|
|
1544
|
+
if (_context19.t0.EqualAddress.call(_context19.t0, _context19.t1, _context19.t2)) {
|
|
1545
|
+
_context19.next = 21;
|
|
2102
1546
|
break;
|
|
2103
1547
|
}
|
|
2104
1548
|
headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
|
|
2105
1549
|
case 21:
|
|
2106
|
-
|
|
2107
|
-
|
|
1550
|
+
_context19.t3 = this;
|
|
1551
|
+
_context19.next = 24;
|
|
2108
1552
|
return this.EncryptionConk({
|
|
2109
1553
|
libraryId: libraryId,
|
|
2110
1554
|
objectId: objectId,
|
|
2111
1555
|
download: true
|
|
2112
1556
|
});
|
|
2113
1557
|
case 24:
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
conk:
|
|
2123
|
-
downloadPath:
|
|
2124
|
-
bytesTotal:
|
|
2125
|
-
headers:
|
|
2126
|
-
callback:
|
|
2127
|
-
format:
|
|
2128
|
-
chunked:
|
|
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
|
|
2129
1573
|
};
|
|
2130
|
-
|
|
2131
|
-
return
|
|
1574
|
+
_context19.next = 34;
|
|
1575
|
+
return _context19.t3.DownloadEncrypted.call(_context19.t3, _context19.t11);
|
|
2132
1576
|
case 34:
|
|
2133
|
-
return
|
|
1577
|
+
return _context19.abrupt("return", _context19.sent);
|
|
2134
1578
|
case 37:
|
|
2135
|
-
|
|
1579
|
+
_context19.next = 39;
|
|
2136
1580
|
return this.Download({
|
|
2137
1581
|
downloadPath: path,
|
|
2138
1582
|
bytesTotal: bytesTotal,
|
|
@@ -2143,26 +1587,26 @@ exports.DownloadPart = /*#__PURE__*/function () {
|
|
|
2143
1587
|
chunkSize: chunkSize
|
|
2144
1588
|
});
|
|
2145
1589
|
case 39:
|
|
2146
|
-
return
|
|
1590
|
+
return _context19.abrupt("return", _context19.sent);
|
|
2147
1591
|
case 40:
|
|
2148
1592
|
case "end":
|
|
2149
|
-
return
|
|
1593
|
+
return _context19.stop();
|
|
2150
1594
|
}
|
|
2151
|
-
},
|
|
1595
|
+
}, _callee18, this);
|
|
2152
1596
|
}));
|
|
2153
|
-
return function (
|
|
2154
|
-
return
|
|
1597
|
+
return function (_x19) {
|
|
1598
|
+
return _ref34.apply(this, arguments);
|
|
2155
1599
|
};
|
|
2156
1600
|
}();
|
|
2157
1601
|
exports.Download = /*#__PURE__*/function () {
|
|
2158
|
-
var
|
|
2159
|
-
var downloadPath, headers, bytesTotal,
|
|
2160
|
-
return _regeneratorRuntime.wrap(function
|
|
2161
|
-
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) {
|
|
2162
1606
|
case 0:
|
|
2163
|
-
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;
|
|
2164
1608
|
if (!(chunked && !callback)) {
|
|
2165
|
-
|
|
1609
|
+
_context20.next = 3;
|
|
2166
1610
|
break;
|
|
2167
1611
|
}
|
|
2168
1612
|
throw Error("No callback specified for chunked download");
|
|
@@ -2177,47 +1621,47 @@ exports.Download = /*#__PURE__*/function () {
|
|
|
2177
1621
|
i = 0;
|
|
2178
1622
|
case 7:
|
|
2179
1623
|
if (!(i < totalChunks)) {
|
|
2180
|
-
|
|
1624
|
+
_context20.next = 35;
|
|
2181
1625
|
break;
|
|
2182
1626
|
}
|
|
2183
1627
|
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
2184
|
-
|
|
1628
|
+
_context20.next = 11;
|
|
2185
1629
|
return this.HttpClient.Request({
|
|
2186
1630
|
path: downloadPath,
|
|
2187
1631
|
headers: headers,
|
|
2188
1632
|
method: "GET"
|
|
2189
1633
|
});
|
|
2190
1634
|
case 11:
|
|
2191
|
-
response =
|
|
1635
|
+
response = _context20.sent;
|
|
2192
1636
|
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
2193
1637
|
if (!chunked) {
|
|
2194
|
-
|
|
1638
|
+
_context20.next = 24;
|
|
2195
1639
|
break;
|
|
2196
1640
|
}
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
1641
|
+
_context20.t0 = callback;
|
|
1642
|
+
_context20.t1 = bytesFinished;
|
|
1643
|
+
_context20.t2 = bytesTotal;
|
|
1644
|
+
_context20.next = 19;
|
|
2201
1645
|
return this.utils.ResponseToFormat(format, response);
|
|
2202
1646
|
case 19:
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
bytesFinished:
|
|
2206
|
-
bytesTotal:
|
|
2207
|
-
chunk:
|
|
1647
|
+
_context20.t3 = _context20.sent;
|
|
1648
|
+
_context20.t4 = {
|
|
1649
|
+
bytesFinished: _context20.t1,
|
|
1650
|
+
bytesTotal: _context20.t2,
|
|
1651
|
+
chunk: _context20.t3
|
|
2208
1652
|
};
|
|
2209
|
-
(0,
|
|
2210
|
-
|
|
1653
|
+
(0, _context20.t0)(_context20.t4);
|
|
1654
|
+
_context20.next = 32;
|
|
2211
1655
|
break;
|
|
2212
1656
|
case 24:
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
1657
|
+
_context20.t5 = outputChunks;
|
|
1658
|
+
_context20.t6 = Buffer;
|
|
1659
|
+
_context20.next = 28;
|
|
2216
1660
|
return response.arrayBuffer();
|
|
2217
1661
|
case 28:
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
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);
|
|
2221
1665
|
if (callback) {
|
|
2222
1666
|
callback({
|
|
2223
1667
|
bytesFinished: bytesFinished,
|
|
@@ -2226,37 +1670,37 @@ exports.Download = /*#__PURE__*/function () {
|
|
|
2226
1670
|
}
|
|
2227
1671
|
case 32:
|
|
2228
1672
|
i++;
|
|
2229
|
-
|
|
1673
|
+
_context20.next = 7;
|
|
2230
1674
|
break;
|
|
2231
1675
|
case 35:
|
|
2232
1676
|
if (chunked) {
|
|
2233
|
-
|
|
1677
|
+
_context20.next = 39;
|
|
2234
1678
|
break;
|
|
2235
1679
|
}
|
|
2236
|
-
|
|
1680
|
+
_context20.next = 38;
|
|
2237
1681
|
return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
|
|
2238
1682
|
case 38:
|
|
2239
|
-
return
|
|
1683
|
+
return _context20.abrupt("return", _context20.sent);
|
|
2240
1684
|
case 39:
|
|
2241
1685
|
case "end":
|
|
2242
|
-
return
|
|
1686
|
+
return _context20.stop();
|
|
2243
1687
|
}
|
|
2244
|
-
},
|
|
1688
|
+
}, _callee19, this);
|
|
2245
1689
|
}));
|
|
2246
|
-
return function (
|
|
2247
|
-
return
|
|
1690
|
+
return function (_x20) {
|
|
1691
|
+
return _ref36.apply(this, arguments);
|
|
2248
1692
|
};
|
|
2249
1693
|
}();
|
|
2250
1694
|
exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
2251
|
-
var
|
|
2252
|
-
var
|
|
2253
|
-
var conk, downloadPath, bytesTotal, headers, callback,
|
|
2254
|
-
return _regeneratorRuntime.wrap(function
|
|
2255
|
-
while (1) switch (
|
|
1695
|
+
var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref37) {
|
|
1696
|
+
var _this2 = this;
|
|
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) {
|
|
2256
1700
|
case 0:
|
|
2257
|
-
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;
|
|
2258
1702
|
if (!(chunked && !callback)) {
|
|
2259
|
-
|
|
1703
|
+
_context22.next = 3;
|
|
2260
1704
|
break;
|
|
2261
1705
|
}
|
|
2262
1706
|
throw Error("No callback specified for chunked download");
|
|
@@ -2267,44 +1711,44 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
2267
1711
|
bytesFinished = 0;
|
|
2268
1712
|
format = format.toLowerCase();
|
|
2269
1713
|
outputChunks = []; // Set up decryption stream
|
|
2270
|
-
|
|
1714
|
+
_context22.next = 10;
|
|
2271
1715
|
return this.Crypto.OpenDecryptionStream(conk);
|
|
2272
1716
|
case 10:
|
|
2273
|
-
stream =
|
|
1717
|
+
stream = _context22.sent;
|
|
2274
1718
|
stream.on("data", /*#__PURE__*/function () {
|
|
2275
|
-
var
|
|
1719
|
+
var _ref39 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(chunk) {
|
|
2276
1720
|
var arrayBuffer;
|
|
2277
|
-
return _regeneratorRuntime.wrap(function
|
|
2278
|
-
while (1) switch (
|
|
1721
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context21) {
|
|
1722
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2279
1723
|
case 0:
|
|
2280
1724
|
if (!chunked) {
|
|
2281
|
-
|
|
1725
|
+
_context21.next = 13;
|
|
2282
1726
|
break;
|
|
2283
1727
|
}
|
|
2284
1728
|
if (!(format !== "buffer")) {
|
|
2285
|
-
|
|
1729
|
+
_context21.next = 10;
|
|
2286
1730
|
break;
|
|
2287
1731
|
}
|
|
2288
1732
|
arrayBuffer = chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength);
|
|
2289
1733
|
if (!(format === "arraybuffer")) {
|
|
2290
|
-
|
|
1734
|
+
_context21.next = 7;
|
|
2291
1735
|
break;
|
|
2292
1736
|
}
|
|
2293
1737
|
chunk = arrayBuffer;
|
|
2294
|
-
|
|
1738
|
+
_context21.next = 10;
|
|
2295
1739
|
break;
|
|
2296
1740
|
case 7:
|
|
2297
|
-
|
|
2298
|
-
return
|
|
1741
|
+
_context21.next = 9;
|
|
1742
|
+
return _this2.utils.ResponseToFormat(format, new Response(arrayBuffer));
|
|
2299
1743
|
case 9:
|
|
2300
|
-
chunk =
|
|
1744
|
+
chunk = _context21.sent;
|
|
2301
1745
|
case 10:
|
|
2302
1746
|
callback({
|
|
2303
1747
|
bytesFinished: bytesFinished,
|
|
2304
1748
|
bytesTotal: bytesTotal,
|
|
2305
1749
|
chunk: chunk
|
|
2306
1750
|
});
|
|
2307
|
-
|
|
1751
|
+
_context21.next = 15;
|
|
2308
1752
|
break;
|
|
2309
1753
|
case 13:
|
|
2310
1754
|
if (callback) {
|
|
@@ -2316,47 +1760,47 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
2316
1760
|
outputChunks.push(chunk);
|
|
2317
1761
|
case 15:
|
|
2318
1762
|
case "end":
|
|
2319
|
-
return
|
|
1763
|
+
return _context21.stop();
|
|
2320
1764
|
}
|
|
2321
|
-
},
|
|
1765
|
+
}, _callee20);
|
|
2322
1766
|
}));
|
|
2323
|
-
return function (
|
|
2324
|
-
return
|
|
1767
|
+
return function (_x22) {
|
|
1768
|
+
return _ref39.apply(this, arguments);
|
|
2325
1769
|
};
|
|
2326
1770
|
}());
|
|
2327
1771
|
totalChunks = Math.ceil(bytesTotal / chunkSize);
|
|
2328
1772
|
i = 0;
|
|
2329
1773
|
case 14:
|
|
2330
1774
|
if (!(i < totalChunks)) {
|
|
2331
|
-
|
|
1775
|
+
_context22.next = 30;
|
|
2332
1776
|
break;
|
|
2333
1777
|
}
|
|
2334
1778
|
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
2335
|
-
|
|
1779
|
+
_context22.next = 18;
|
|
2336
1780
|
return this.HttpClient.Request({
|
|
2337
1781
|
headers: headers,
|
|
2338
1782
|
method: "GET",
|
|
2339
1783
|
path: downloadPath
|
|
2340
1784
|
});
|
|
2341
1785
|
case 18:
|
|
2342
|
-
response =
|
|
1786
|
+
response = _context22.sent;
|
|
2343
1787
|
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
1788
|
+
_context22.t0 = stream;
|
|
1789
|
+
_context22.t1 = Uint8Array;
|
|
1790
|
+
_context22.next = 24;
|
|
2347
1791
|
return response.arrayBuffer();
|
|
2348
1792
|
case 24:
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
1793
|
+
_context22.t2 = _context22.sent;
|
|
1794
|
+
_context22.t3 = new _context22.t1(_context22.t2);
|
|
1795
|
+
_context22.t0.write.call(_context22.t0, _context22.t3);
|
|
2352
1796
|
case 27:
|
|
2353
1797
|
i++;
|
|
2354
|
-
|
|
1798
|
+
_context22.next = 14;
|
|
2355
1799
|
break;
|
|
2356
1800
|
case 30:
|
|
2357
1801
|
// Wait for decryption to complete
|
|
2358
1802
|
stream.end();
|
|
2359
|
-
|
|
1803
|
+
_context22.next = 33;
|
|
2360
1804
|
return new Promise(function (resolve) {
|
|
2361
1805
|
return stream.on("finish", function () {
|
|
2362
1806
|
resolve();
|
|
@@ -2364,21 +1808,21 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
2364
1808
|
});
|
|
2365
1809
|
case 33:
|
|
2366
1810
|
if (chunked) {
|
|
2367
|
-
|
|
1811
|
+
_context22.next = 37;
|
|
2368
1812
|
break;
|
|
2369
1813
|
}
|
|
2370
|
-
|
|
1814
|
+
_context22.next = 36;
|
|
2371
1815
|
return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
|
|
2372
1816
|
case 36:
|
|
2373
|
-
return
|
|
1817
|
+
return _context22.abrupt("return", _context22.sent);
|
|
2374
1818
|
case 37:
|
|
2375
1819
|
case "end":
|
|
2376
|
-
return
|
|
1820
|
+
return _context22.stop();
|
|
2377
1821
|
}
|
|
2378
|
-
},
|
|
1822
|
+
}, _callee21, this);
|
|
2379
1823
|
}));
|
|
2380
|
-
return function (
|
|
2381
|
-
return
|
|
1824
|
+
return function (_x21) {
|
|
1825
|
+
return _ref38.apply(this, arguments);
|
|
2382
1826
|
};
|
|
2383
1827
|
}();
|
|
2384
1828
|
|
|
@@ -2396,20 +1840,20 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
2396
1840
|
* @returns {Promise<string>} - The part write token for the part draft
|
|
2397
1841
|
*/
|
|
2398
1842
|
exports.CreatePart = /*#__PURE__*/function () {
|
|
2399
|
-
var
|
|
1843
|
+
var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref40) {
|
|
2400
1844
|
var libraryId, objectId, writeToken, encryption, path, openResponse;
|
|
2401
|
-
return _regeneratorRuntime.wrap(function
|
|
2402
|
-
while (1) switch (
|
|
1845
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context23) {
|
|
1846
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2403
1847
|
case 0:
|
|
2404
|
-
libraryId =
|
|
1848
|
+
libraryId = _ref40.libraryId, objectId = _ref40.objectId, writeToken = _ref40.writeToken, encryption = _ref40.encryption;
|
|
2405
1849
|
ValidateParameters({
|
|
2406
1850
|
libraryId: libraryId,
|
|
2407
1851
|
objectId: objectId
|
|
2408
1852
|
});
|
|
2409
1853
|
ValidateWriteToken(writeToken);
|
|
2410
1854
|
path = UrlJoin("q", writeToken, "parts");
|
|
2411
|
-
|
|
2412
|
-
|
|
1855
|
+
_context23.t0 = this.HttpClient;
|
|
1856
|
+
_context23.next = 7;
|
|
2413
1857
|
return this.authClient.AuthorizationHeader({
|
|
2414
1858
|
libraryId: libraryId,
|
|
2415
1859
|
objectId: objectId,
|
|
@@ -2417,29 +1861,29 @@ exports.CreatePart = /*#__PURE__*/function () {
|
|
|
2417
1861
|
encryption: encryption
|
|
2418
1862
|
});
|
|
2419
1863
|
case 7:
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
headers:
|
|
1864
|
+
_context23.t1 = _context23.sent;
|
|
1865
|
+
_context23.t2 = path;
|
|
1866
|
+
_context23.t3 = {
|
|
1867
|
+
headers: _context23.t1,
|
|
2424
1868
|
method: "POST",
|
|
2425
|
-
path:
|
|
1869
|
+
path: _context23.t2,
|
|
2426
1870
|
bodyType: "BINARY",
|
|
2427
1871
|
body: "",
|
|
2428
1872
|
allowFailover: false
|
|
2429
1873
|
};
|
|
2430
|
-
|
|
2431
|
-
return
|
|
1874
|
+
_context23.next = 12;
|
|
1875
|
+
return _context23.t0.RequestJsonBody.call(_context23.t0, _context23.t3);
|
|
2432
1876
|
case 12:
|
|
2433
|
-
openResponse =
|
|
2434
|
-
return
|
|
1877
|
+
openResponse = _context23.sent;
|
|
1878
|
+
return _context23.abrupt("return", openResponse.part.write_token);
|
|
2435
1879
|
case 14:
|
|
2436
1880
|
case "end":
|
|
2437
|
-
return
|
|
1881
|
+
return _context23.stop();
|
|
2438
1882
|
}
|
|
2439
|
-
},
|
|
1883
|
+
}, _callee22, this);
|
|
2440
1884
|
}));
|
|
2441
|
-
return function (
|
|
2442
|
-
return
|
|
1885
|
+
return function (_x23) {
|
|
1886
|
+
return _ref41.apply(this, arguments);
|
|
2443
1887
|
};
|
|
2444
1888
|
}();
|
|
2445
1889
|
|
|
@@ -2459,38 +1903,38 @@ exports.CreatePart = /*#__PURE__*/function () {
|
|
|
2459
1903
|
* @returns {Promise<string>} - The part write token for the part draft
|
|
2460
1904
|
*/
|
|
2461
1905
|
exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
2462
|
-
var
|
|
1906
|
+
var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref42) {
|
|
2463
1907
|
var libraryId, objectId, writeToken, partWriteToken, chunk, encryption, conk, path;
|
|
2464
|
-
return _regeneratorRuntime.wrap(function
|
|
2465
|
-
while (1) switch (
|
|
1908
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context24) {
|
|
1909
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2466
1910
|
case 0:
|
|
2467
|
-
libraryId =
|
|
1911
|
+
libraryId = _ref42.libraryId, objectId = _ref42.objectId, writeToken = _ref42.writeToken, partWriteToken = _ref42.partWriteToken, chunk = _ref42.chunk, encryption = _ref42.encryption;
|
|
2468
1912
|
ValidateParameters({
|
|
2469
1913
|
libraryId: libraryId,
|
|
2470
1914
|
objectId: objectId
|
|
2471
1915
|
});
|
|
2472
1916
|
ValidateWriteToken(writeToken);
|
|
2473
1917
|
if (!(encryption && encryption !== "none")) {
|
|
2474
|
-
|
|
1918
|
+
_context24.next = 10;
|
|
2475
1919
|
break;
|
|
2476
1920
|
}
|
|
2477
|
-
|
|
1921
|
+
_context24.next = 6;
|
|
2478
1922
|
return this.EncryptionConk({
|
|
2479
1923
|
libraryId: libraryId,
|
|
2480
1924
|
objectId: objectId,
|
|
2481
1925
|
writeToken: writeToken
|
|
2482
1926
|
});
|
|
2483
1927
|
case 6:
|
|
2484
|
-
conk =
|
|
2485
|
-
|
|
1928
|
+
conk = _context24.sent;
|
|
1929
|
+
_context24.next = 9;
|
|
2486
1930
|
return this.Crypto.Encrypt(conk, chunk);
|
|
2487
1931
|
case 9:
|
|
2488
|
-
chunk =
|
|
1932
|
+
chunk = _context24.sent;
|
|
2489
1933
|
case 10:
|
|
2490
1934
|
path = UrlJoin("q", writeToken, "parts");
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
1935
|
+
_context24.t0 = this.utils;
|
|
1936
|
+
_context24.t1 = this.HttpClient;
|
|
1937
|
+
_context24.next = 15;
|
|
2494
1938
|
return this.authClient.AuthorizationHeader({
|
|
2495
1939
|
libraryId: libraryId,
|
|
2496
1940
|
objectId: objectId,
|
|
@@ -2498,28 +1942,28 @@ exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
|
2498
1942
|
encryption: encryption
|
|
2499
1943
|
});
|
|
2500
1944
|
case 15:
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
headers:
|
|
1945
|
+
_context24.t2 = _context24.sent;
|
|
1946
|
+
_context24.t3 = UrlJoin(path, partWriteToken);
|
|
1947
|
+
_context24.t4 = chunk;
|
|
1948
|
+
_context24.t5 = {
|
|
1949
|
+
headers: _context24.t2,
|
|
2506
1950
|
method: "POST",
|
|
2507
|
-
path:
|
|
2508
|
-
body:
|
|
1951
|
+
path: _context24.t3,
|
|
1952
|
+
body: _context24.t4,
|
|
2509
1953
|
bodyType: "BINARY",
|
|
2510
1954
|
allowFailover: false
|
|
2511
1955
|
};
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
return
|
|
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);
|
|
2515
1959
|
case 22:
|
|
2516
1960
|
case "end":
|
|
2517
|
-
return
|
|
1961
|
+
return _context24.stop();
|
|
2518
1962
|
}
|
|
2519
|
-
},
|
|
1963
|
+
}, _callee23, this);
|
|
2520
1964
|
}));
|
|
2521
|
-
return function (
|
|
2522
|
-
return
|
|
1965
|
+
return function (_x24) {
|
|
1966
|
+
return _ref43.apply(this, arguments);
|
|
2523
1967
|
};
|
|
2524
1968
|
}();
|
|
2525
1969
|
|
|
@@ -2538,20 +1982,20 @@ exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
|
2538
1982
|
* @returns {Promise<object>} - The finalize response for the new part
|
|
2539
1983
|
*/
|
|
2540
1984
|
exports.FinalizePart = /*#__PURE__*/function () {
|
|
2541
|
-
var
|
|
1985
|
+
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref44) {
|
|
2542
1986
|
var libraryId, objectId, writeToken, partWriteToken, encryption, path;
|
|
2543
|
-
return _regeneratorRuntime.wrap(function
|
|
2544
|
-
while (1) switch (
|
|
1987
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context25) {
|
|
1988
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2545
1989
|
case 0:
|
|
2546
|
-
libraryId =
|
|
1990
|
+
libraryId = _ref44.libraryId, objectId = _ref44.objectId, writeToken = _ref44.writeToken, partWriteToken = _ref44.partWriteToken, encryption = _ref44.encryption;
|
|
2547
1991
|
ValidateParameters({
|
|
2548
1992
|
libraryId: libraryId,
|
|
2549
1993
|
objectId: objectId
|
|
2550
1994
|
});
|
|
2551
1995
|
ValidateWriteToken(writeToken);
|
|
2552
1996
|
path = UrlJoin("q", writeToken, "parts");
|
|
2553
|
-
|
|
2554
|
-
|
|
1997
|
+
_context25.t0 = this.HttpClient;
|
|
1998
|
+
_context25.next = 7;
|
|
2555
1999
|
return this.authClient.AuthorizationHeader({
|
|
2556
2000
|
libraryId: libraryId,
|
|
2557
2001
|
objectId: objectId,
|
|
@@ -2559,28 +2003,28 @@ exports.FinalizePart = /*#__PURE__*/function () {
|
|
|
2559
2003
|
encryption: encryption
|
|
2560
2004
|
});
|
|
2561
2005
|
case 7:
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
headers:
|
|
2006
|
+
_context25.t1 = _context25.sent;
|
|
2007
|
+
_context25.t2 = UrlJoin(path, partWriteToken);
|
|
2008
|
+
_context25.t3 = {
|
|
2009
|
+
headers: _context25.t1,
|
|
2566
2010
|
method: "POST",
|
|
2567
|
-
path:
|
|
2011
|
+
path: _context25.t2,
|
|
2568
2012
|
bodyType: "BINARY",
|
|
2569
2013
|
body: "",
|
|
2570
2014
|
allowFailover: false
|
|
2571
2015
|
};
|
|
2572
|
-
|
|
2573
|
-
return
|
|
2016
|
+
_context25.next = 12;
|
|
2017
|
+
return _context25.t0.RequestJsonBody.call(_context25.t0, _context25.t3);
|
|
2574
2018
|
case 12:
|
|
2575
|
-
return
|
|
2019
|
+
return _context25.abrupt("return", _context25.sent);
|
|
2576
2020
|
case 13:
|
|
2577
2021
|
case "end":
|
|
2578
|
-
return
|
|
2022
|
+
return _context25.stop();
|
|
2579
2023
|
}
|
|
2580
|
-
},
|
|
2024
|
+
}, _callee24, this);
|
|
2581
2025
|
}));
|
|
2582
|
-
return function (
|
|
2583
|
-
return
|
|
2026
|
+
return function (_x25) {
|
|
2027
|
+
return _ref45.apply(this, arguments);
|
|
2584
2028
|
};
|
|
2585
2029
|
}();
|
|
2586
2030
|
|
|
@@ -2606,18 +2050,18 @@ exports.FinalizePart = /*#__PURE__*/function () {
|
|
|
2606
2050
|
* @returns {Promise<Object>} - Response containing information about the uploaded part
|
|
2607
2051
|
*/
|
|
2608
2052
|
exports.UploadPart = /*#__PURE__*/function () {
|
|
2609
|
-
var
|
|
2610
|
-
var libraryId, objectId, writeToken, data,
|
|
2611
|
-
return _regeneratorRuntime.wrap(function
|
|
2612
|
-
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) {
|
|
2613
2057
|
case 0:
|
|
2614
|
-
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;
|
|
2615
2059
|
ValidateParameters({
|
|
2616
2060
|
libraryId: libraryId,
|
|
2617
2061
|
objectId: objectId
|
|
2618
2062
|
});
|
|
2619
2063
|
ValidateWriteToken(writeToken);
|
|
2620
|
-
|
|
2064
|
+
_context26.next = 5;
|
|
2621
2065
|
return this.CreatePart({
|
|
2622
2066
|
libraryId: libraryId,
|
|
2623
2067
|
objectId: objectId,
|
|
@@ -2625,7 +2069,7 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2625
2069
|
encryption: encryption
|
|
2626
2070
|
});
|
|
2627
2071
|
case 5:
|
|
2628
|
-
partWriteToken =
|
|
2072
|
+
partWriteToken = _context26.sent;
|
|
2629
2073
|
size = data.length || data.byteLength || data.size;
|
|
2630
2074
|
if (callback) {
|
|
2631
2075
|
callback({
|
|
@@ -2636,11 +2080,11 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2636
2080
|
i = 0;
|
|
2637
2081
|
case 9:
|
|
2638
2082
|
if (!(i < size)) {
|
|
2639
|
-
|
|
2083
|
+
_context26.next = 17;
|
|
2640
2084
|
break;
|
|
2641
2085
|
}
|
|
2642
2086
|
chunk = data.slice(i, i + chunkSize);
|
|
2643
|
-
|
|
2087
|
+
_context26.next = 13;
|
|
2644
2088
|
return this.UploadPartChunk({
|
|
2645
2089
|
libraryId: libraryId,
|
|
2646
2090
|
objectId: objectId,
|
|
@@ -2658,10 +2102,10 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2658
2102
|
}
|
|
2659
2103
|
case 14:
|
|
2660
2104
|
i += chunkSize;
|
|
2661
|
-
|
|
2105
|
+
_context26.next = 9;
|
|
2662
2106
|
break;
|
|
2663
2107
|
case 17:
|
|
2664
|
-
|
|
2108
|
+
_context26.next = 19;
|
|
2665
2109
|
return this.FinalizePart({
|
|
2666
2110
|
libraryId: libraryId,
|
|
2667
2111
|
objectId: objectId,
|
|
@@ -2670,15 +2114,15 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2670
2114
|
encryption: encryption
|
|
2671
2115
|
});
|
|
2672
2116
|
case 19:
|
|
2673
|
-
return
|
|
2117
|
+
return _context26.abrupt("return", _context26.sent);
|
|
2674
2118
|
case 20:
|
|
2675
2119
|
case "end":
|
|
2676
|
-
return
|
|
2120
|
+
return _context26.stop();
|
|
2677
2121
|
}
|
|
2678
|
-
},
|
|
2122
|
+
}, _callee25, this);
|
|
2679
2123
|
}));
|
|
2680
|
-
return function (
|
|
2681
|
-
return
|
|
2124
|
+
return function (_x26) {
|
|
2125
|
+
return _ref47.apply(this, arguments);
|
|
2682
2126
|
};
|
|
2683
2127
|
}();
|
|
2684
2128
|
|
|
@@ -2694,12 +2138,12 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2694
2138
|
* @param {string} partHash - Hash of the part to delete
|
|
2695
2139
|
*/
|
|
2696
2140
|
exports.DeletePart = /*#__PURE__*/function () {
|
|
2697
|
-
var
|
|
2141
|
+
var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref48) {
|
|
2698
2142
|
var libraryId, objectId, writeToken, partHash, path;
|
|
2699
|
-
return _regeneratorRuntime.wrap(function
|
|
2700
|
-
while (1) switch (
|
|
2143
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context27) {
|
|
2144
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2701
2145
|
case 0:
|
|
2702
|
-
libraryId =
|
|
2146
|
+
libraryId = _ref48.libraryId, objectId = _ref48.objectId, writeToken = _ref48.writeToken, partHash = _ref48.partHash;
|
|
2703
2147
|
ValidateParameters({
|
|
2704
2148
|
libraryId: libraryId,
|
|
2705
2149
|
objectId: objectId
|
|
@@ -2707,31 +2151,31 @@ exports.DeletePart = /*#__PURE__*/function () {
|
|
|
2707
2151
|
ValidateWriteToken(writeToken);
|
|
2708
2152
|
ValidatePartHash(partHash);
|
|
2709
2153
|
path = UrlJoin("q", writeToken, "parts", partHash);
|
|
2710
|
-
|
|
2711
|
-
|
|
2154
|
+
_context27.t0 = this.HttpClient;
|
|
2155
|
+
_context27.next = 8;
|
|
2712
2156
|
return this.authClient.AuthorizationHeader({
|
|
2713
2157
|
libraryId: libraryId,
|
|
2714
2158
|
objectId: objectId,
|
|
2715
2159
|
update: true
|
|
2716
2160
|
});
|
|
2717
2161
|
case 8:
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
headers:
|
|
2162
|
+
_context27.t1 = _context27.sent;
|
|
2163
|
+
_context27.t2 = path;
|
|
2164
|
+
_context27.t3 = {
|
|
2165
|
+
headers: _context27.t1,
|
|
2722
2166
|
method: "DELETE",
|
|
2723
|
-
path:
|
|
2167
|
+
path: _context27.t2,
|
|
2724
2168
|
allowFailover: false
|
|
2725
2169
|
};
|
|
2726
|
-
|
|
2727
|
-
return
|
|
2170
|
+
_context27.next = 13;
|
|
2171
|
+
return _context27.t0.Request.call(_context27.t0, _context27.t3);
|
|
2728
2172
|
case 13:
|
|
2729
2173
|
case "end":
|
|
2730
|
-
return
|
|
2174
|
+
return _context27.stop();
|
|
2731
2175
|
}
|
|
2732
|
-
},
|
|
2176
|
+
}, _callee26, this);
|
|
2733
2177
|
}));
|
|
2734
|
-
return function (
|
|
2735
|
-
return
|
|
2178
|
+
return function (_x27) {
|
|
2179
|
+
return _ref49.apply(this, arguments);
|
|
2736
2180
|
};
|
|
2737
2181
|
}();
|