@eluvio/elv-client-js 4.0.11 → 4.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.keep +0 -0
- package/dist/ElvClient-min.js +11 -10
- package/dist/ElvClient-node-min.js +11 -10
- package/dist/ElvFrameClient-min.js +11 -10
- package/dist/ElvPermissionsClient-min.js +10 -9
- package/dist/ElvWalletClient-min.js +10 -9
- package/dist/ElvWalletClient-node-min.js +10 -9
- package/dist/src/AuthorizationClient.js +1555 -2076
- package/dist/src/ContentObjectVerification.js +134 -185
- package/dist/src/Crypto.js +224 -319
- package/dist/src/ElvClient.js +822 -1114
- package/dist/src/ElvWallet.js +64 -106
- package/dist/src/EthClient.js +719 -974
- package/dist/src/FrameClient.js +223 -319
- package/dist/src/HttpClient.js +117 -156
- package/dist/src/Id.js +1 -6
- package/dist/src/LogMessage.js +4 -8
- package/dist/src/PermissionsClient.js +973 -1271
- package/dist/src/RemoteSigner.js +161 -232
- package/dist/src/UserProfileClient.js +781 -1038
- package/dist/src/Utils.js +159 -299
- package/dist/src/Validation.js +2 -17
- package/dist/src/client/ABRPublishing.js +828 -958
- package/dist/src/client/AccessGroups.js +849 -1095
- package/dist/src/client/ContentAccess.js +3323 -4195
- package/dist/src/client/ContentManagement.js +1818 -2290
- package/dist/src/client/Contracts.js +468 -614
- package/dist/src/client/Files.js +1506 -1846
- package/dist/src/client/NFT.js +94 -116
- package/dist/src/client/NTP.js +326 -425
- package/dist/src/index.js +2 -5
- package/dist/src/walletClient/ClientMethods.js +1368 -1763
- package/dist/src/walletClient/Configuration.js +5 -3
- package/dist/src/walletClient/Notifications.js +98 -127
- package/dist/src/walletClient/Profile.js +184 -246
- package/dist/src/walletClient/Utils.js +76 -122
- package/dist/src/walletClient/index.js +1171 -1496
- package/package.json +4 -21
- package/src/FrameClient.js +1 -0
- package/src/HttpClient.js +4 -2
- package/src/client/ABRPublishing.js +126 -105
- package/src/client/ContentAccess.js +1 -0
- package/src/client/ContentManagement.js +4 -2
- package/src/walletClient/Configuration.js +3 -2
- package/dist/AccessClient-min.js +0 -54
- package/dist/AccessClient-node-min.js +0 -74
- package/dist/src/AccessClient.js +0 -798
- package/dist/src/LimitedMap.js +0 -120
- package/dist/src/client/Access.js +0 -1
- package/dist/src/client/Management.js +0 -1606
- package/dist/src/contracts/AccessIndexor.js +0 -831
- package/dist/src/contracts/Accessible.js +0 -31
- package/dist/src/contracts/AdmgrAdvertisement.js +0 -695
- package/dist/src/contracts/AdmgrCampaign.js +0 -648
- package/dist/src/contracts/AdmgrCampaignManager.js +0 -493
- package/dist/src/contracts/AdmgrCommercialOffering.js +0 -622
- package/dist/src/contracts/AdmgrCommercialOfferingManager.js +0 -413
- package/dist/src/contracts/AdmgrMarketPlace.js +0 -413
- package/dist/src/contracts/AvailsDelivery.js +0 -535
- package/dist/src/contracts/BaseAccessControlGroup.js +0 -1221
- package/dist/src/contracts/BaseAccessWallet.js +0 -1575
- package/dist/src/contracts/BaseAccessWalletFactory.js +0 -93
- package/dist/src/contracts/BaseContent.js +0 -1104
- package/dist/src/contracts/BaseContentFactory.js +0 -99
- package/dist/src/contracts/BaseContentFactoryExt.js +0 -219
- package/dist/src/contracts/BaseContentSpace.js +0 -1346
- package/dist/src/contracts/BaseContentType.js +0 -353
- package/dist/src/contracts/BaseFactory.js +0 -107
- package/dist/src/contracts/BaseGroupFactory.js +0 -93
- package/dist/src/contracts/BaseLibrary.js +0 -1035
- package/dist/src/contracts/BaseLibraryFactory.js +0 -96
- package/dist/src/contracts/Certifyer.js +0 -87
- package/dist/src/contracts/Container.js +0 -543
- package/dist/src/contracts/Content.js +0 -432
- package/dist/src/contracts/Editable.js +0 -295
- package/dist/src/contracts/FactorySpace.js +0 -57
- package/dist/src/contracts/KmsSpace.js +0 -52
- package/dist/src/contracts/LvProvider.js +0 -512
- package/dist/src/contracts/LvRecordableStream.js +0 -1026
- package/dist/src/contracts/LvRecording.js +0 -627
- package/dist/src/contracts/LvStreamRightsHolder.js +0 -551
- package/dist/src/contracts/MetaObject.js +0 -110
- package/dist/src/contracts/Node.js +0 -167
- package/dist/src/contracts/NodeSpace.js +0 -18
- package/dist/src/contracts/NodeSpaceImpl.js +0 -273
- package/dist/src/contracts/Ownable.js +0 -87
- package/dist/src/contracts/PaymentService.js +0 -616
- package/dist/src/contracts/Precompile.js +0 -15
- package/dist/src/contracts/SampleContentAdMarketplace.js +0 -564
- package/dist/src/contracts/SampleContentAdvertising.js +0 -444
- package/dist/src/contracts/SampleContentHelloWorld.js +0 -459
- package/dist/src/contracts/SampleContentLicensing.js +0 -618
- package/dist/src/contracts/SampleContentSigned.js +0 -447
- package/dist/src/contracts/SampleInstance.js +0 -438
- package/dist/src/contracts/SampleInstanceFactory.js +0 -451
- package/dist/src/contracts/Transactable.js +0 -82
- package/dist/src/contracts/UserSpace.js +0 -18
- package/dist/src/contracts/UserSpaceImpl.js +0 -43
- package/dist/src/contracts/Utils.js +0 -18
- package/dist/src/contracts/Verifier.js +0 -53
- package/dist/src/contracts/strings.js +0 -4
- package/dist/src/contracts/v2/BaseContentFactoryExt.js +0 -219
- package/dist/src/contracts/v2/FactorySpace.js +0 -57
- package/dist/src/contracts/v2/KmsSpace.js +0 -52
- package/dist/src/contracts/v2/NodeSpaceImpl.js +0 -273
- package/dist/src/contracts/v2/UserSpaceImpl.js +0 -43
- package/dist/src/marketplaceClient/ClientMethods.js +0 -1918
- package/dist/src/marketplaceClient/Configuration.js +0 -29
- package/dist/src/marketplaceClient/Utils.js +0 -304
- package/dist/src/marketplaceClient/index.js +0 -1553
- package/utilities/ListAccessGroups.js +0 -34
package/dist/src/client/Files.js
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
2
|
-
|
|
3
2
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
4
|
-
|
|
5
3
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
6
|
-
|
|
7
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
6
|
/**
|
|
12
7
|
* Methods for accessing and managing access groups
|
|
13
8
|
*
|
|
14
9
|
* @module ElvClient/Files+Parts
|
|
15
10
|
*/
|
|
16
|
-
var Utils = require("../Utils");
|
|
17
11
|
|
|
12
|
+
var Utils = require("../Utils");
|
|
18
13
|
var fs;
|
|
19
|
-
|
|
20
14
|
if (Utils.Platform() === Utils.PLATFORM_NODE) {
|
|
21
15
|
// Define Response in node
|
|
22
16
|
// eslint-disable-next-line no-global-assign
|
|
23
17
|
globalThis.Response = require("node-fetch").Response;
|
|
24
18
|
fs = require("fs");
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
var UrlJoin = require("url-join");
|
|
28
|
-
|
|
29
21
|
var _require = require("../Validation"),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
ValidatePresence = _require.ValidatePresence,
|
|
23
|
+
ValidateWriteToken = _require.ValidateWriteToken,
|
|
24
|
+
ValidatePartHash = _require.ValidatePartHash,
|
|
25
|
+
ValidateParameters = _require.ValidateParameters;
|
|
26
|
+
|
|
34
27
|
/* Files */
|
|
35
28
|
|
|
36
29
|
/**
|
|
@@ -43,59 +36,51 @@ var _require = require("../Validation"),
|
|
|
43
36
|
* @param {string=} objectId - ID of the object
|
|
44
37
|
* @param {string=} versionHash - Hash of the object version - if not specified, most recent version will be used
|
|
45
38
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
39
|
exports.ListFiles = /*#__PURE__*/function () {
|
|
49
40
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
50
41
|
var libraryId, objectId, versionHash, path;
|
|
51
42
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
52
|
-
while (1) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
_context.t3
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return _context.abrupt("return", _context.t0.ResponseToJson.call(_context.t0, _context.t5));
|
|
86
|
-
|
|
87
|
-
case 13:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
libraryId = _ref.libraryId, objectId = _ref.objectId, versionHash = _ref.versionHash;
|
|
46
|
+
ValidateParameters({
|
|
47
|
+
libraryId: libraryId,
|
|
48
|
+
objectId: objectId,
|
|
49
|
+
versionHash: versionHash
|
|
50
|
+
});
|
|
51
|
+
if (versionHash) {
|
|
52
|
+
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
53
|
+
}
|
|
54
|
+
path = UrlJoin("q", versionHash || objectId, "meta", "files");
|
|
55
|
+
_context.t0 = this.utils;
|
|
56
|
+
_context.t1 = this.HttpClient;
|
|
57
|
+
_context.next = 8;
|
|
58
|
+
return this.authClient.AuthorizationHeader({
|
|
59
|
+
libraryId: libraryId,
|
|
60
|
+
objectId: objectId,
|
|
61
|
+
versionHash: versionHash
|
|
62
|
+
});
|
|
63
|
+
case 8:
|
|
64
|
+
_context.t2 = _context.sent;
|
|
65
|
+
_context.t3 = path;
|
|
66
|
+
_context.t4 = {
|
|
67
|
+
headers: _context.t2,
|
|
68
|
+
method: "GET",
|
|
69
|
+
path: _context.t3
|
|
70
|
+
};
|
|
71
|
+
_context.t5 = _context.t1.Request.call(_context.t1, _context.t4);
|
|
72
|
+
return _context.abrupt("return", _context.t0.ResponseToJson.call(_context.t0, _context.t5));
|
|
73
|
+
case 13:
|
|
74
|
+
case "end":
|
|
75
|
+
return _context.stop();
|
|
91
76
|
}
|
|
92
77
|
}, _callee, this);
|
|
93
78
|
}));
|
|
94
|
-
|
|
95
79
|
return function (_x) {
|
|
96
80
|
return _ref2.apply(this, arguments);
|
|
97
81
|
};
|
|
98
82
|
}();
|
|
83
|
+
|
|
99
84
|
/**
|
|
100
85
|
* Copy/reference files from S3 to a content object.
|
|
101
86
|
*
|
|
@@ -130,243 +115,202 @@ exports.ListFiles = /*#__PURE__*/function () {
|
|
|
130
115
|
* - Arguments (copy): { done: boolean, uploaded: number, total: number, uploadedFiles: number, totalFiles: number, fileStatus: Object }
|
|
131
116
|
* - Arguments (reference): { done: boolean, uploadedFiles: number, totalFiles: number }
|
|
132
117
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
118
|
exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
136
119
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
137
120
|
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;
|
|
138
|
-
|
|
139
121
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
140
|
-
while (1) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
case 5:
|
|
155
|
-
if (!(i < fileInfo.length)) {
|
|
156
|
-
_context2.next = 18;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
fileSourcePath = fileInfo[i].source;
|
|
161
|
-
s3prefixMatch = s3prefixRegex.exec(fileSourcePath);
|
|
162
|
-
|
|
163
|
-
if (!s3prefixMatch) {
|
|
164
|
-
_context2.next = 15;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
bucketName = s3prefixMatch[1];
|
|
169
|
-
|
|
170
|
-
if (!(bucketName !== bucket)) {
|
|
171
|
-
_context2.next = 14;
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
throw Error("Full S3 file path \"" + fileSourcePath + "\" specified, but does not match provided bucket name '" + bucket + "'");
|
|
176
|
-
|
|
177
|
-
case 14:
|
|
178
|
-
// strip prefix
|
|
179
|
-
fileInfo[i].source = fileSourcePath.replace(s3prefixRegex, "");
|
|
180
|
-
|
|
181
|
-
case 15:
|
|
182
|
-
i++;
|
|
183
|
-
_context2.next = 5;
|
|
122
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
123
|
+
case 0:
|
|
124
|
+
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;
|
|
125
|
+
ValidateParameters({
|
|
126
|
+
libraryId: libraryId,
|
|
127
|
+
objectId: objectId
|
|
128
|
+
});
|
|
129
|
+
ValidateWriteToken(writeToken);
|
|
130
|
+
s3prefixRegex = /^s3:\/\/([^/]+)\//i; // for matching and extracting bucket name when full s3:// path is specified
|
|
131
|
+
// if fileInfo source paths start with s3://bucketName/, check against bucket arg passed in, and strip
|
|
132
|
+
i = 0;
|
|
133
|
+
case 5:
|
|
134
|
+
if (!(i < fileInfo.length)) {
|
|
135
|
+
_context2.next = 18;
|
|
184
136
|
break;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
_context2.next =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
137
|
+
}
|
|
138
|
+
fileSourcePath = fileInfo[i].source;
|
|
139
|
+
s3prefixMatch = s3prefixRegex.exec(fileSourcePath);
|
|
140
|
+
if (!s3prefixMatch) {
|
|
141
|
+
_context2.next = 15;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
bucketName = s3prefixMatch[1];
|
|
145
|
+
if (!(bucketName !== bucket)) {
|
|
146
|
+
_context2.next = 14;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
throw Error("Full S3 file path \"" + fileSourcePath + "\" specified, but does not match provided bucket name '" + bucket + "'");
|
|
150
|
+
case 14:
|
|
151
|
+
// strip prefix
|
|
152
|
+
fileInfo[i].source = fileSourcePath.replace(s3prefixRegex, "");
|
|
153
|
+
case 15:
|
|
154
|
+
i++;
|
|
155
|
+
_context2.next = 5;
|
|
156
|
+
break;
|
|
157
|
+
case 18:
|
|
158
|
+
this.Log("Uploading files from S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
159
|
+
if (!(encryption === "cgck")) {
|
|
160
|
+
_context2.next = 25;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
_context2.next = 22;
|
|
164
|
+
return this.EncryptionConk({
|
|
165
|
+
libraryId: libraryId,
|
|
166
|
+
objectId: objectId,
|
|
167
|
+
writeToken: writeToken
|
|
168
|
+
});
|
|
169
|
+
case 22:
|
|
170
|
+
conk = _context2.sent;
|
|
171
|
+
conk = _objectSpread(_objectSpread({}, conk), {}, {
|
|
172
|
+
secret_key: ""
|
|
173
|
+
});
|
|
174
|
+
encryption_key = "kp__".concat(this.utils.B58(Buffer.from(JSON.stringify(conk))));
|
|
175
|
+
case 25:
|
|
176
|
+
cloudCredentials = {
|
|
177
|
+
access_key_id: accessKey,
|
|
178
|
+
secret_access_key: secret
|
|
179
|
+
};
|
|
180
|
+
if (signedUrl) {
|
|
209
181
|
cloudCredentials = {
|
|
210
|
-
|
|
211
|
-
secret_access_key: secret
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
if (signedUrl) {
|
|
215
|
-
cloudCredentials = {
|
|
216
|
-
signed_url: signedUrl
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
defaults = {
|
|
221
|
-
encryption_key: encryption_key,
|
|
222
|
-
access: {
|
|
223
|
-
protocol: "s3",
|
|
224
|
-
platform: "aws",
|
|
225
|
-
path: bucket,
|
|
226
|
-
storage_endpoint: {
|
|
227
|
-
region: region
|
|
228
|
-
},
|
|
229
|
-
cloud_credentials: cloudCredentials
|
|
230
|
-
}
|
|
182
|
+
signed_url: signedUrl
|
|
231
183
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
} else {
|
|
246
|
-
return {
|
|
247
|
-
op: "add-reference",
|
|
248
|
-
path: info.path,
|
|
249
|
-
reference: {
|
|
250
|
-
type: "key",
|
|
251
|
-
path: info.source
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
}); // eslint-disable-next-line no-unused-vars
|
|
256
|
-
|
|
257
|
-
_context2.next = 31;
|
|
258
|
-
return this.CreateFileUploadJob({
|
|
259
|
-
libraryId: libraryId,
|
|
260
|
-
objectId: objectId,
|
|
261
|
-
writeToken: writeToken,
|
|
262
|
-
ops: ops,
|
|
263
|
-
defaults: defaults
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
case 31:
|
|
267
|
-
_yield$this$CreateFil = _context2.sent;
|
|
268
|
-
id = _yield$this$CreateFil.id;
|
|
269
|
-
|
|
270
|
-
case 33:
|
|
271
|
-
if (!true) {
|
|
272
|
-
_context2.next = 56;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
_context2.next = 36;
|
|
277
|
-
return new Promise(function (resolve) {
|
|
278
|
-
return setTimeout(resolve, 1000);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
case 36:
|
|
282
|
-
_context2.next = 38;
|
|
283
|
-
return this.UploadStatus({
|
|
284
|
-
libraryId: libraryId,
|
|
285
|
-
objectId: objectId,
|
|
286
|
-
writeToken: writeToken,
|
|
287
|
-
uploadId: id
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
case 38:
|
|
291
|
-
status = _context2.sent;
|
|
292
|
-
|
|
293
|
-
if (!(status.errors && status.errors.length > 1)) {
|
|
294
|
-
_context2.next = 43;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
throw status.errors.join("\n");
|
|
299
|
-
|
|
300
|
-
case 43:
|
|
301
|
-
if (!status.error) {
|
|
302
|
-
_context2.next = 48;
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
this.Log("S3 file upload failed:\n".concat(JSON.stringify(status, null, 2)));
|
|
307
|
-
throw status.error;
|
|
308
|
-
|
|
309
|
-
case 48:
|
|
310
|
-
if (!(status.status.toLowerCase() === "failed")) {
|
|
311
|
-
_context2.next = 50;
|
|
312
|
-
break;
|
|
184
|
+
}
|
|
185
|
+
defaults = {
|
|
186
|
+
encryption_key: encryption_key,
|
|
187
|
+
access: {
|
|
188
|
+
protocol: "s3",
|
|
189
|
+
platform: "aws",
|
|
190
|
+
path: bucket,
|
|
191
|
+
storage_endpoint: {
|
|
192
|
+
region: region
|
|
193
|
+
},
|
|
194
|
+
cloud_credentials: cloudCredentials
|
|
313
195
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
case 50:
|
|
318
|
-
done = false;
|
|
319
|
-
|
|
196
|
+
};
|
|
197
|
+
ops = fileInfo.map(function (info) {
|
|
320
198
|
if (copy) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
});
|
|
333
|
-
}
|
|
199
|
+
return {
|
|
200
|
+
op: "ingest-copy",
|
|
201
|
+
path: info.path,
|
|
202
|
+
encryption: {
|
|
203
|
+
scheme: encryption === "cgck" ? "cgck" : "none"
|
|
204
|
+
},
|
|
205
|
+
ingest: {
|
|
206
|
+
type: "key",
|
|
207
|
+
path: info.source
|
|
208
|
+
}
|
|
209
|
+
};
|
|
334
210
|
} else {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
});
|
|
344
|
-
}
|
|
211
|
+
return {
|
|
212
|
+
op: "add-reference",
|
|
213
|
+
path: info.path,
|
|
214
|
+
reference: {
|
|
215
|
+
type: "key",
|
|
216
|
+
path: info.source
|
|
217
|
+
}
|
|
218
|
+
};
|
|
345
219
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
220
|
+
}); // eslint-disable-next-line no-unused-vars
|
|
221
|
+
_context2.next = 31;
|
|
222
|
+
return this.CreateFileUploadJob({
|
|
223
|
+
libraryId: libraryId,
|
|
224
|
+
objectId: objectId,
|
|
225
|
+
writeToken: writeToken,
|
|
226
|
+
ops: ops,
|
|
227
|
+
defaults: defaults
|
|
228
|
+
});
|
|
229
|
+
case 31:
|
|
230
|
+
_yield$this$CreateFil = _context2.sent;
|
|
231
|
+
id = _yield$this$CreateFil.id;
|
|
232
|
+
case 33:
|
|
233
|
+
if (!true) {
|
|
234
|
+
_context2.next = 56;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
_context2.next = 36;
|
|
238
|
+
return new Promise(function (resolve) {
|
|
239
|
+
return setTimeout(resolve, 1000);
|
|
240
|
+
});
|
|
241
|
+
case 36:
|
|
242
|
+
_context2.next = 38;
|
|
243
|
+
return this.UploadStatus({
|
|
244
|
+
libraryId: libraryId,
|
|
245
|
+
objectId: objectId,
|
|
246
|
+
writeToken: writeToken,
|
|
247
|
+
uploadId: id
|
|
248
|
+
});
|
|
249
|
+
case 38:
|
|
250
|
+
status = _context2.sent;
|
|
251
|
+
if (!(status.errors && status.errors.length > 1)) {
|
|
252
|
+
_context2.next = 43;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
throw status.errors.join("\n");
|
|
256
|
+
case 43:
|
|
257
|
+
if (!status.error) {
|
|
258
|
+
_context2.next = 48;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
this.Log("S3 file upload failed:\n".concat(JSON.stringify(status, null, 2)));
|
|
262
|
+
throw status.error;
|
|
263
|
+
case 48:
|
|
264
|
+
if (!(status.status.toLowerCase() === "failed")) {
|
|
265
|
+
_context2.next = 50;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
throw "File upload failed";
|
|
269
|
+
case 50:
|
|
270
|
+
done = false;
|
|
271
|
+
if (copy) {
|
|
272
|
+
done = status.ingest_copy.done;
|
|
273
|
+
if (callback) {
|
|
274
|
+
progress = status.ingest_copy.progress;
|
|
275
|
+
callback({
|
|
276
|
+
done: done,
|
|
277
|
+
uploaded: progress.bytes.completed,
|
|
278
|
+
total: progress.bytes.total,
|
|
279
|
+
uploadedFiles: progress.files.completed,
|
|
280
|
+
totalFiles: progress.files.total,
|
|
281
|
+
fileStatus: progress.files.details
|
|
282
|
+
});
|
|
350
283
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
284
|
+
} else {
|
|
285
|
+
done = status.add_reference.done;
|
|
286
|
+
if (callback) {
|
|
287
|
+
_progress = status.add_reference.progress;
|
|
288
|
+
callback({
|
|
289
|
+
done: done,
|
|
290
|
+
uploadedFiles: _progress.completed,
|
|
291
|
+
totalFiles: _progress.total
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (!done) {
|
|
296
|
+
_context2.next = 54;
|
|
356
297
|
break;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
298
|
+
}
|
|
299
|
+
return _context2.abrupt("break", 56);
|
|
300
|
+
case 54:
|
|
301
|
+
_context2.next = 33;
|
|
302
|
+
break;
|
|
303
|
+
case 56:
|
|
304
|
+
case "end":
|
|
305
|
+
return _context2.stop();
|
|
362
306
|
}
|
|
363
307
|
}, _callee2, this);
|
|
364
308
|
}));
|
|
365
|
-
|
|
366
309
|
return function (_x2) {
|
|
367
310
|
return _ref4.apply(this, arguments);
|
|
368
311
|
};
|
|
369
312
|
}();
|
|
313
|
+
|
|
370
314
|
/**
|
|
371
315
|
* Upload files to a content object.
|
|
372
316
|
*
|
|
@@ -393,629 +337,530 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
393
337
|
* @param {function=} callback - If specified, will be called after each job segment is finished with the current upload progress
|
|
394
338
|
* - Format: {"filename1": {uploaded: number, total: number}, ...}
|
|
395
339
|
*/
|
|
396
|
-
|
|
397
|
-
|
|
398
340
|
exports.UploadFiles = /*#__PURE__*/function () {
|
|
399
341
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref5) {
|
|
400
342
|
var _this = this;
|
|
401
|
-
|
|
402
343
|
var libraryId, objectId, writeToken, fileInfo, _ref5$encryption, encryption, callback, conk, progress, fileDataMap, i, entry, _yield$this$CreateFil2, id, jobs, bufferSize, jobSpecs, prepared, uploaded, PrepareJobs, UploadJob, rateTestJobs, rates, j, start, elapsed, size, averageRate, concurrentUploads;
|
|
403
|
-
|
|
404
344
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
405
|
-
while (1) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
345
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
346
|
+
case 0:
|
|
347
|
+
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;
|
|
348
|
+
ValidateParameters({
|
|
349
|
+
libraryId: libraryId,
|
|
350
|
+
objectId: objectId
|
|
351
|
+
});
|
|
352
|
+
ValidateWriteToken(writeToken);
|
|
353
|
+
this.Log("Uploading files: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
354
|
+
if (!(encryption === "cgck")) {
|
|
355
|
+
_context6.next = 8;
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
_context6.next = 7;
|
|
359
|
+
return this.EncryptionConk({
|
|
360
|
+
libraryId: libraryId,
|
|
361
|
+
objectId: objectId,
|
|
362
|
+
writeToken: writeToken
|
|
363
|
+
});
|
|
364
|
+
case 7:
|
|
365
|
+
conk = _context6.sent;
|
|
366
|
+
case 8:
|
|
367
|
+
// Extract file data into easily accessible hash while removing the data from the fileinfo for upload job creation
|
|
368
|
+
progress = {};
|
|
369
|
+
fileDataMap = {};
|
|
370
|
+
for (i = 0; i < fileInfo.length; i++) {
|
|
371
|
+
entry = _objectSpread(_objectSpread({}, fileInfo[i]), {}, {
|
|
372
|
+
data: undefined
|
|
426
373
|
});
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
case 8:
|
|
432
|
-
// Extract file data into easily accessible hash while removing the data from the fileinfo for upload job creation
|
|
433
|
-
progress = {};
|
|
434
|
-
fileDataMap = {};
|
|
435
|
-
|
|
436
|
-
for (i = 0; i < fileInfo.length; i++) {
|
|
437
|
-
entry = _objectSpread(_objectSpread({}, fileInfo[i]), {}, {
|
|
438
|
-
data: undefined
|
|
439
|
-
});
|
|
440
|
-
entry.path = entry.path.replace(/^\/+/, "");
|
|
441
|
-
|
|
442
|
-
if (encryption === "cgck") {
|
|
443
|
-
entry.encryption = {
|
|
444
|
-
scheme: "cgck"
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
fileDataMap[entry.path] = fileInfo[i].data;
|
|
449
|
-
delete entry.data;
|
|
450
|
-
entry.type = "file";
|
|
451
|
-
progress[entry.path] = {
|
|
452
|
-
uploaded: 0,
|
|
453
|
-
total: entry.size
|
|
374
|
+
entry.path = entry.path.replace(/^\/+/, "");
|
|
375
|
+
if (encryption === "cgck") {
|
|
376
|
+
entry.encryption = {
|
|
377
|
+
scheme: "cgck"
|
|
454
378
|
};
|
|
455
|
-
fileInfo[i] = entry;
|
|
456
379
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
case 2:
|
|
502
|
-
if (!(prepared - uploaded > bufferSize)) {
|
|
503
|
-
_context3.next = 7;
|
|
504
|
-
break;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
_context3.next = 5;
|
|
508
|
-
return new Promise(function (resolve) {
|
|
509
|
-
return setTimeout(resolve, 500);
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
case 5:
|
|
513
|
-
_context3.next = 2;
|
|
514
|
-
break;
|
|
515
|
-
|
|
516
|
-
case 7:
|
|
517
|
-
// Retrieve job info
|
|
518
|
-
jobId = jobs[j];
|
|
519
|
-
_context3.next = 10;
|
|
520
|
-
return _this.UploadJobStatus({
|
|
521
|
-
libraryId: libraryId,
|
|
522
|
-
objectId: objectId,
|
|
523
|
-
writeToken: writeToken,
|
|
524
|
-
uploadId: id,
|
|
525
|
-
jobId: jobId
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
case 10:
|
|
529
|
-
job = _context3.sent;
|
|
530
|
-
f = 0;
|
|
531
|
-
|
|
532
|
-
case 12:
|
|
533
|
-
if (!(f < job.files.length)) {
|
|
534
|
-
_context3.next = 25;
|
|
535
|
-
break;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
_fileInfo = job.files[f];
|
|
539
|
-
data = void 0;
|
|
540
|
-
|
|
541
|
-
if (typeof fileDataMap[_fileInfo.path] === "number") {
|
|
542
|
-
// File descriptor - Read data from file
|
|
543
|
-
data = Buffer.alloc(_fileInfo.len);
|
|
544
|
-
fs.readSync(fileDataMap[_fileInfo.path], data, 0, _fileInfo.len, _fileInfo.off);
|
|
545
|
-
} else {
|
|
546
|
-
// Full data - Slice requested chunk
|
|
547
|
-
data = fileDataMap[_fileInfo.path].slice(_fileInfo.off, _fileInfo.off + _fileInfo.len);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (!(encryption === "cgck")) {
|
|
551
|
-
_context3.next = 20;
|
|
552
|
-
break;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
_context3.next = 19;
|
|
556
|
-
return _this.Crypto.Encrypt(conk, data);
|
|
557
|
-
|
|
558
|
-
case 19:
|
|
559
|
-
data = _context3.sent;
|
|
560
|
-
|
|
561
|
-
case 20:
|
|
562
|
-
job.files[f].data = data;
|
|
563
|
-
prepared += _fileInfo.len;
|
|
564
|
-
|
|
565
|
-
case 22:
|
|
566
|
-
f++;
|
|
567
|
-
_context3.next = 12;
|
|
568
|
-
break;
|
|
569
|
-
|
|
570
|
-
case 25:
|
|
571
|
-
jobSpecs[j] = job; // Wait for a bit to let upload start
|
|
572
|
-
|
|
573
|
-
_context3.next = 28;
|
|
574
|
-
return new Promise(function (resolve) {
|
|
575
|
-
return setTimeout(resolve, 50);
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
case 28:
|
|
579
|
-
j++;
|
|
580
|
-
_context3.next = 1;
|
|
581
|
-
break;
|
|
582
|
-
|
|
583
|
-
case 31:
|
|
584
|
-
case "end":
|
|
585
|
-
return _context3.stop();
|
|
380
|
+
fileDataMap[entry.path] = fileInfo[i].data;
|
|
381
|
+
delete entry.data;
|
|
382
|
+
entry.type = "file";
|
|
383
|
+
progress[entry.path] = {
|
|
384
|
+
uploaded: 0,
|
|
385
|
+
total: entry.size
|
|
386
|
+
};
|
|
387
|
+
fileInfo[i] = entry;
|
|
388
|
+
}
|
|
389
|
+
this.Log(fileInfo);
|
|
390
|
+
if (callback) {
|
|
391
|
+
callback(progress);
|
|
392
|
+
}
|
|
393
|
+
_context6.next = 15;
|
|
394
|
+
return this.CreateFileUploadJob({
|
|
395
|
+
libraryId: libraryId,
|
|
396
|
+
objectId: objectId,
|
|
397
|
+
writeToken: writeToken,
|
|
398
|
+
ops: fileInfo,
|
|
399
|
+
encryption: encryption
|
|
400
|
+
});
|
|
401
|
+
case 15:
|
|
402
|
+
_yield$this$CreateFil2 = _context6.sent;
|
|
403
|
+
id = _yield$this$CreateFil2.id;
|
|
404
|
+
jobs = _yield$this$CreateFil2.jobs;
|
|
405
|
+
this.Log("Upload ID: ".concat(id));
|
|
406
|
+
this.Log(jobs);
|
|
407
|
+
|
|
408
|
+
// How far encryption can get ahead of upload
|
|
409
|
+
bufferSize = 100 * 1024 * 1024;
|
|
410
|
+
jobSpecs = [];
|
|
411
|
+
prepared = 0;
|
|
412
|
+
uploaded = 0; // Insert the data to upload into the job spec, encrypting if necessary
|
|
413
|
+
PrepareJobs = /*#__PURE__*/function () {
|
|
414
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
415
|
+
var j, jobId, job, f, _fileInfo, data;
|
|
416
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
417
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
418
|
+
case 0:
|
|
419
|
+
j = 0;
|
|
420
|
+
case 1:
|
|
421
|
+
if (!(j < jobs.length)) {
|
|
422
|
+
_context3.next = 31;
|
|
423
|
+
break;
|
|
586
424
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
return function PrepareJobs() {
|
|
592
|
-
return _ref7.apply(this, arguments);
|
|
593
|
-
};
|
|
594
|
-
}();
|
|
595
|
-
|
|
596
|
-
UploadJob = /*#__PURE__*/function () {
|
|
597
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobId, j) {
|
|
598
|
-
var jobSpec, files, f, _fileInfo2;
|
|
599
|
-
|
|
600
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
601
|
-
while (1) {
|
|
602
|
-
switch (_context4.prev = _context4.next) {
|
|
603
|
-
case 0:
|
|
604
|
-
if (jobSpecs[j]) {
|
|
605
|
-
_context4.next = 5;
|
|
606
|
-
break;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
_context4.next = 3;
|
|
610
|
-
return new Promise(function (resolve) {
|
|
611
|
-
return setTimeout(resolve, 500);
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
case 3:
|
|
615
|
-
_context4.next = 0;
|
|
616
|
-
break;
|
|
617
|
-
|
|
618
|
-
case 5:
|
|
619
|
-
jobSpec = jobSpecs[j];
|
|
620
|
-
files = jobSpec.files; // Upload each item
|
|
621
|
-
|
|
622
|
-
f = 0;
|
|
623
|
-
|
|
624
|
-
case 8:
|
|
625
|
-
if (!(f < files.length)) {
|
|
626
|
-
_context4.next = 18;
|
|
627
|
-
break;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
_fileInfo2 = files[f];
|
|
631
|
-
_context4.next = 12;
|
|
632
|
-
return _this.UploadFileData({
|
|
633
|
-
libraryId: libraryId,
|
|
634
|
-
objectId: objectId,
|
|
635
|
-
writeToken: writeToken,
|
|
636
|
-
uploadId: id,
|
|
637
|
-
jobId: jobId,
|
|
638
|
-
fileData: _fileInfo2.data
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
case 12:
|
|
642
|
-
delete jobSpecs[j].files[f].data;
|
|
643
|
-
uploaded += _fileInfo2.len;
|
|
644
|
-
|
|
645
|
-
if (callback) {
|
|
646
|
-
progress[_fileInfo2.path] = _objectSpread(_objectSpread({}, progress[_fileInfo2.path]), {}, {
|
|
647
|
-
uploaded: progress[_fileInfo2.path].uploaded + _fileInfo2.len
|
|
648
|
-
});
|
|
649
|
-
callback(progress);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
case 15:
|
|
653
|
-
f++;
|
|
654
|
-
_context4.next = 8;
|
|
655
|
-
break;
|
|
656
|
-
|
|
657
|
-
case 18:
|
|
658
|
-
case "end":
|
|
659
|
-
return _context4.stop();
|
|
425
|
+
case 2:
|
|
426
|
+
if (!(prepared - uploaded > bufferSize)) {
|
|
427
|
+
_context3.next = 7;
|
|
428
|
+
break;
|
|
660
429
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
430
|
+
_context3.next = 5;
|
|
431
|
+
return new Promise(function (resolve) {
|
|
432
|
+
return setTimeout(resolve, 500);
|
|
433
|
+
});
|
|
434
|
+
case 5:
|
|
435
|
+
_context3.next = 2;
|
|
436
|
+
break;
|
|
437
|
+
case 7:
|
|
438
|
+
// Retrieve job info
|
|
439
|
+
jobId = jobs[j];
|
|
440
|
+
_context3.next = 10;
|
|
441
|
+
return _this.UploadJobStatus({
|
|
442
|
+
libraryId: libraryId,
|
|
443
|
+
objectId: objectId,
|
|
444
|
+
writeToken: writeToken,
|
|
445
|
+
uploadId: id,
|
|
446
|
+
jobId: jobId
|
|
447
|
+
});
|
|
448
|
+
case 10:
|
|
449
|
+
job = _context3.sent;
|
|
450
|
+
f = 0;
|
|
451
|
+
case 12:
|
|
452
|
+
if (!(f < job.files.length)) {
|
|
453
|
+
_context3.next = 25;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
_fileInfo = job.files[f];
|
|
457
|
+
data = void 0;
|
|
458
|
+
if (typeof fileDataMap[_fileInfo.path] === "number") {
|
|
459
|
+
// File descriptor - Read data from file
|
|
460
|
+
data = Buffer.alloc(_fileInfo.len);
|
|
461
|
+
fs.readSync(fileDataMap[_fileInfo.path], data, 0, _fileInfo.len, _fileInfo.off);
|
|
462
|
+
} else {
|
|
463
|
+
// Full data - Slice requested chunk
|
|
464
|
+
data = fileDataMap[_fileInfo.path].slice(_fileInfo.off, _fileInfo.off + _fileInfo.len);
|
|
465
|
+
}
|
|
466
|
+
if (!(encryption === "cgck")) {
|
|
467
|
+
_context3.next = 20;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
_context3.next = 19;
|
|
471
|
+
return _this.Crypto.Encrypt(conk, data);
|
|
472
|
+
case 19:
|
|
473
|
+
data = _context3.sent;
|
|
474
|
+
case 20:
|
|
475
|
+
job.files[f].data = data;
|
|
476
|
+
prepared += _fileInfo.len;
|
|
477
|
+
case 22:
|
|
478
|
+
f++;
|
|
479
|
+
_context3.next = 12;
|
|
480
|
+
break;
|
|
481
|
+
case 25:
|
|
482
|
+
jobSpecs[j] = job;
|
|
483
|
+
|
|
484
|
+
// Wait for a bit to let upload start
|
|
485
|
+
_context3.next = 28;
|
|
486
|
+
return new Promise(function (resolve) {
|
|
487
|
+
return setTimeout(resolve, 50);
|
|
488
|
+
});
|
|
489
|
+
case 28:
|
|
490
|
+
j++;
|
|
491
|
+
_context3.next = 1;
|
|
492
|
+
break;
|
|
493
|
+
case 31:
|
|
494
|
+
case "end":
|
|
495
|
+
return _context3.stop();
|
|
496
|
+
}
|
|
497
|
+
}, _callee3);
|
|
498
|
+
}));
|
|
499
|
+
return function PrepareJobs() {
|
|
500
|
+
return _ref7.apply(this, arguments);
|
|
501
|
+
};
|
|
502
|
+
}();
|
|
503
|
+
UploadJob = /*#__PURE__*/function () {
|
|
504
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(jobId, j) {
|
|
505
|
+
var jobSpec, files, f, _fileInfo2;
|
|
506
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
507
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
508
|
+
case 0:
|
|
509
|
+
if (jobSpecs[j]) {
|
|
510
|
+
_context4.next = 5;
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
_context4.next = 3;
|
|
514
|
+
return new Promise(function (resolve) {
|
|
515
|
+
return setTimeout(resolve, 500);
|
|
516
|
+
});
|
|
517
|
+
case 3:
|
|
518
|
+
_context4.next = 0;
|
|
519
|
+
break;
|
|
520
|
+
case 5:
|
|
521
|
+
jobSpec = jobSpecs[j];
|
|
522
|
+
files = jobSpec.files; // Upload each item
|
|
523
|
+
f = 0;
|
|
524
|
+
case 8:
|
|
525
|
+
if (!(f < files.length)) {
|
|
526
|
+
_context4.next = 18;
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
_fileInfo2 = files[f];
|
|
530
|
+
_context4.next = 12;
|
|
531
|
+
return _this.UploadFileData({
|
|
532
|
+
libraryId: libraryId,
|
|
533
|
+
objectId: objectId,
|
|
534
|
+
writeToken: writeToken,
|
|
535
|
+
uploadId: id,
|
|
536
|
+
jobId: jobId,
|
|
537
|
+
fileData: _fileInfo2.data
|
|
538
|
+
});
|
|
539
|
+
case 12:
|
|
540
|
+
delete jobSpecs[j].files[f].data;
|
|
541
|
+
uploaded += _fileInfo2.len;
|
|
542
|
+
if (callback) {
|
|
543
|
+
progress[_fileInfo2.path] = _objectSpread(_objectSpread({}, progress[_fileInfo2.path]), {}, {
|
|
544
|
+
uploaded: progress[_fileInfo2.path].uploaded + _fileInfo2.len
|
|
545
|
+
});
|
|
546
|
+
callback(progress);
|
|
547
|
+
}
|
|
548
|
+
case 15:
|
|
549
|
+
f++;
|
|
550
|
+
_context4.next = 8;
|
|
551
|
+
break;
|
|
552
|
+
case 18:
|
|
553
|
+
case "end":
|
|
554
|
+
return _context4.stop();
|
|
555
|
+
}
|
|
556
|
+
}, _callee4);
|
|
557
|
+
}));
|
|
558
|
+
return function UploadJob(_x4, _x5) {
|
|
559
|
+
return _ref8.apply(this, arguments);
|
|
560
|
+
};
|
|
561
|
+
}(); // Preparing jobs is done asyncronously
|
|
562
|
+
PrepareJobs();
|
|
563
|
+
|
|
564
|
+
// Upload the first several chunks in sequence, to determine average upload rate
|
|
565
|
+
rateTestJobs = Math.min(3, jobs.length);
|
|
566
|
+
rates = [];
|
|
567
|
+
j = 0;
|
|
568
|
+
case 30:
|
|
569
|
+
if (!(j < rateTestJobs)) {
|
|
570
|
+
_context6.next = 40;
|
|
699
571
|
break;
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
572
|
+
}
|
|
573
|
+
start = new Date().getTime();
|
|
574
|
+
_context6.next = 34;
|
|
575
|
+
return UploadJob(jobs[j], j);
|
|
576
|
+
case 34:
|
|
577
|
+
elapsed = (new Date().getTime() - start) / 1000;
|
|
578
|
+
size = jobSpecs[j].files.map(function (file) {
|
|
579
|
+
return file.len;
|
|
580
|
+
}).reduce(function (length, total) {
|
|
581
|
+
return length + total;
|
|
582
|
+
}, 0);
|
|
583
|
+
rates.push(size / elapsed / (1024 * 1024));
|
|
584
|
+
case 37:
|
|
585
|
+
j++;
|
|
586
|
+
_context6.next = 30;
|
|
587
|
+
break;
|
|
588
|
+
case 40:
|
|
589
|
+
averageRate = rates.reduce(function (mbps, total) {
|
|
590
|
+
return mbps + total;
|
|
591
|
+
}, 0) / rateTestJobs; // Upload remaining jobs in parallel
|
|
592
|
+
concurrentUploads = Math.min(5, Math.ceil(averageRate / 2));
|
|
593
|
+
_context6.next = 44;
|
|
594
|
+
return this.utils.LimitedMap(concurrentUploads, jobs, /*#__PURE__*/function () {
|
|
595
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(jobId, j) {
|
|
596
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
597
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
598
|
+
case 0:
|
|
599
|
+
if (!(j < rateTestJobs)) {
|
|
600
|
+
_context5.next = 2;
|
|
601
|
+
break;
|
|
728
602
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
603
|
+
return _context5.abrupt("return");
|
|
604
|
+
case 2:
|
|
605
|
+
_context5.next = 4;
|
|
606
|
+
return UploadJob(jobId, j);
|
|
607
|
+
case 4:
|
|
608
|
+
case "end":
|
|
609
|
+
return _context5.stop();
|
|
610
|
+
}
|
|
611
|
+
}, _callee5);
|
|
612
|
+
}));
|
|
613
|
+
return function (_x6, _x7) {
|
|
614
|
+
return _ref9.apply(this, arguments);
|
|
615
|
+
};
|
|
616
|
+
}());
|
|
617
|
+
case 44:
|
|
618
|
+
case "end":
|
|
619
|
+
return _context6.stop();
|
|
742
620
|
}
|
|
743
621
|
}, _callee6, this);
|
|
744
622
|
}));
|
|
745
|
-
|
|
746
623
|
return function (_x3) {
|
|
747
624
|
return _ref6.apply(this, arguments);
|
|
748
625
|
};
|
|
749
626
|
}();
|
|
750
|
-
|
|
751
627
|
exports.CreateFileUploadJob = /*#__PURE__*/function () {
|
|
752
628
|
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
|
|
753
629
|
var libraryId, objectId, writeToken, ops, _ref10$defaults, defaults, _ref10$encryption, encryption, body, path;
|
|
754
|
-
|
|
755
630
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
756
|
-
while (1) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
defaults.encryption = {
|
|
770
|
-
scheme: "cgck"
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
body = {
|
|
775
|
-
seq: 0,
|
|
776
|
-
seq_complete: true,
|
|
777
|
-
defaults: defaults,
|
|
778
|
-
ops: ops
|
|
631
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
632
|
+
case 0:
|
|
633
|
+
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;
|
|
634
|
+
ValidateParameters({
|
|
635
|
+
libraryId: libraryId,
|
|
636
|
+
objectId: objectId
|
|
637
|
+
});
|
|
638
|
+
ValidateWriteToken(writeToken);
|
|
639
|
+
this.Log("Creating file upload job: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
640
|
+
this.Log(ops);
|
|
641
|
+
if (encryption === "cgck") {
|
|
642
|
+
defaults.encryption = {
|
|
643
|
+
scheme: "cgck"
|
|
779
644
|
};
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
645
|
+
}
|
|
646
|
+
body = {
|
|
647
|
+
seq: 0,
|
|
648
|
+
seq_complete: true,
|
|
649
|
+
defaults: defaults,
|
|
650
|
+
ops: ops
|
|
651
|
+
};
|
|
652
|
+
path = UrlJoin("q", writeToken, "file_jobs");
|
|
653
|
+
_context7.t0 = this.utils;
|
|
654
|
+
_context7.t1 = this.HttpClient;
|
|
655
|
+
_context7.next = 12;
|
|
656
|
+
return this.authClient.AuthorizationHeader({
|
|
657
|
+
libraryId: libraryId,
|
|
658
|
+
objectId: objectId,
|
|
659
|
+
update: true,
|
|
660
|
+
encryption: encryption
|
|
661
|
+
});
|
|
662
|
+
case 12:
|
|
663
|
+
_context7.t2 = _context7.sent;
|
|
664
|
+
_context7.t3 = path;
|
|
665
|
+
_context7.t4 = body;
|
|
666
|
+
_context7.t5 = {
|
|
667
|
+
headers: _context7.t2,
|
|
668
|
+
method: "POST",
|
|
669
|
+
path: _context7.t3,
|
|
670
|
+
body: _context7.t4,
|
|
671
|
+
failover: false
|
|
672
|
+
};
|
|
673
|
+
_context7.t6 = _context7.t1.Request.call(_context7.t1, _context7.t5);
|
|
674
|
+
return _context7.abrupt("return", _context7.t0.ResponseToJson.call(_context7.t0, _context7.t6));
|
|
675
|
+
case 18:
|
|
676
|
+
case "end":
|
|
677
|
+
return _context7.stop();
|
|
809
678
|
}
|
|
810
679
|
}, _callee7, this);
|
|
811
680
|
}));
|
|
812
|
-
|
|
813
681
|
return function (_x8) {
|
|
814
682
|
return _ref11.apply(this, arguments);
|
|
815
683
|
};
|
|
816
684
|
}();
|
|
817
|
-
|
|
818
685
|
exports.UploadStatus = /*#__PURE__*/function () {
|
|
819
686
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
820
687
|
var libraryId, objectId, writeToken, uploadId, path;
|
|
821
688
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
822
|
-
while (1) {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
_context8.
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
case 13:
|
|
854
|
-
case "end":
|
|
855
|
-
return _context8.stop();
|
|
856
|
-
}
|
|
689
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
690
|
+
case 0:
|
|
691
|
+
libraryId = _ref12.libraryId, objectId = _ref12.objectId, writeToken = _ref12.writeToken, uploadId = _ref12.uploadId;
|
|
692
|
+
ValidateParameters({
|
|
693
|
+
libraryId: libraryId,
|
|
694
|
+
objectId: objectId
|
|
695
|
+
});
|
|
696
|
+
ValidateWriteToken(writeToken);
|
|
697
|
+
path = UrlJoin("q", writeToken, "file_jobs", uploadId);
|
|
698
|
+
_context8.t0 = this.utils;
|
|
699
|
+
_context8.t1 = this.HttpClient;
|
|
700
|
+
_context8.next = 8;
|
|
701
|
+
return this.authClient.AuthorizationHeader({
|
|
702
|
+
libraryId: libraryId,
|
|
703
|
+
objectId: objectId,
|
|
704
|
+
update: true
|
|
705
|
+
});
|
|
706
|
+
case 8:
|
|
707
|
+
_context8.t2 = _context8.sent;
|
|
708
|
+
_context8.t3 = path;
|
|
709
|
+
_context8.t4 = {
|
|
710
|
+
headers: _context8.t2,
|
|
711
|
+
method: "GET",
|
|
712
|
+
path: _context8.t3,
|
|
713
|
+
failover: false
|
|
714
|
+
};
|
|
715
|
+
_context8.t5 = _context8.t1.Request.call(_context8.t1, _context8.t4);
|
|
716
|
+
return _context8.abrupt("return", _context8.t0.ResponseToJson.call(_context8.t0, _context8.t5));
|
|
717
|
+
case 13:
|
|
718
|
+
case "end":
|
|
719
|
+
return _context8.stop();
|
|
857
720
|
}
|
|
858
721
|
}, _callee8, this);
|
|
859
722
|
}));
|
|
860
|
-
|
|
861
723
|
return function (_x9) {
|
|
862
724
|
return _ref13.apply(this, arguments);
|
|
863
725
|
};
|
|
864
726
|
}();
|
|
865
|
-
|
|
866
727
|
exports.UploadJobStatus = /*#__PURE__*/function () {
|
|
867
728
|
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref14) {
|
|
868
729
|
var libraryId, objectId, writeToken, uploadId, jobId, path;
|
|
869
730
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
870
|
-
while (1) {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
_context9.
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
case 13:
|
|
902
|
-
case "end":
|
|
903
|
-
return _context9.stop();
|
|
904
|
-
}
|
|
731
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
732
|
+
case 0:
|
|
733
|
+
libraryId = _ref14.libraryId, objectId = _ref14.objectId, writeToken = _ref14.writeToken, uploadId = _ref14.uploadId, jobId = _ref14.jobId;
|
|
734
|
+
ValidateParameters({
|
|
735
|
+
libraryId: libraryId,
|
|
736
|
+
objectId: objectId
|
|
737
|
+
});
|
|
738
|
+
ValidateWriteToken(writeToken);
|
|
739
|
+
path = UrlJoin("q", writeToken, "file_jobs", uploadId, "uploads", jobId);
|
|
740
|
+
_context9.t0 = this.utils;
|
|
741
|
+
_context9.t1 = this.HttpClient;
|
|
742
|
+
_context9.next = 8;
|
|
743
|
+
return this.authClient.AuthorizationHeader({
|
|
744
|
+
libraryId: libraryId,
|
|
745
|
+
objectId: objectId,
|
|
746
|
+
update: true
|
|
747
|
+
});
|
|
748
|
+
case 8:
|
|
749
|
+
_context9.t2 = _context9.sent;
|
|
750
|
+
_context9.t3 = path;
|
|
751
|
+
_context9.t4 = {
|
|
752
|
+
headers: _context9.t2,
|
|
753
|
+
method: "GET",
|
|
754
|
+
path: _context9.t3,
|
|
755
|
+
failover: false
|
|
756
|
+
};
|
|
757
|
+
_context9.t5 = _context9.t1.Request.call(_context9.t1, _context9.t4);
|
|
758
|
+
return _context9.abrupt("return", _context9.t0.ResponseToJson.call(_context9.t0, _context9.t5));
|
|
759
|
+
case 13:
|
|
760
|
+
case "end":
|
|
761
|
+
return _context9.stop();
|
|
905
762
|
}
|
|
906
763
|
}, _callee9, this);
|
|
907
764
|
}));
|
|
908
|
-
|
|
909
765
|
return function (_x10) {
|
|
910
766
|
return _ref15.apply(this, arguments);
|
|
911
767
|
};
|
|
912
768
|
}();
|
|
913
|
-
|
|
914
769
|
exports.UploadFileData = /*#__PURE__*/function () {
|
|
915
770
|
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref16) {
|
|
916
771
|
var libraryId, objectId, writeToken, uploadId, jobId, fileData, path;
|
|
917
772
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
918
|
-
while (1) {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
_context10.
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
case 18:
|
|
959
|
-
case "end":
|
|
960
|
-
return _context10.stop();
|
|
961
|
-
}
|
|
773
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
774
|
+
case 0:
|
|
775
|
+
libraryId = _ref16.libraryId, objectId = _ref16.objectId, writeToken = _ref16.writeToken, uploadId = _ref16.uploadId, jobId = _ref16.jobId, fileData = _ref16.fileData;
|
|
776
|
+
ValidateParameters({
|
|
777
|
+
libraryId: libraryId,
|
|
778
|
+
objectId: objectId
|
|
779
|
+
});
|
|
780
|
+
ValidateWriteToken(writeToken);
|
|
781
|
+
path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
|
|
782
|
+
_context10.t0 = this.utils;
|
|
783
|
+
_context10.t1 = this.HttpClient;
|
|
784
|
+
_context10.t2 = path;
|
|
785
|
+
_context10.t3 = fileData;
|
|
786
|
+
_context10.t4 = _objectSpread;
|
|
787
|
+
_context10.t5 = {
|
|
788
|
+
"Content-type": "application/octet-stream"
|
|
789
|
+
};
|
|
790
|
+
_context10.next = 12;
|
|
791
|
+
return this.authClient.AuthorizationHeader({
|
|
792
|
+
libraryId: libraryId,
|
|
793
|
+
objectId: objectId,
|
|
794
|
+
update: true
|
|
795
|
+
});
|
|
796
|
+
case 12:
|
|
797
|
+
_context10.t6 = _context10.sent;
|
|
798
|
+
_context10.t7 = (0, _context10.t4)(_context10.t5, _context10.t6);
|
|
799
|
+
_context10.t8 = {
|
|
800
|
+
method: "POST",
|
|
801
|
+
path: _context10.t2,
|
|
802
|
+
body: _context10.t3,
|
|
803
|
+
bodyType: "BINARY",
|
|
804
|
+
headers: _context10.t7,
|
|
805
|
+
failover: false
|
|
806
|
+
};
|
|
807
|
+
_context10.t9 = _context10.t1.Request.call(_context10.t1, _context10.t8);
|
|
808
|
+
_context10.next = 18;
|
|
809
|
+
return _context10.t0.ResponseToJson.call(_context10.t0, _context10.t9);
|
|
810
|
+
case 18:
|
|
811
|
+
case "end":
|
|
812
|
+
return _context10.stop();
|
|
962
813
|
}
|
|
963
814
|
}, _callee10, this);
|
|
964
815
|
}));
|
|
965
|
-
|
|
966
816
|
return function (_x11) {
|
|
967
817
|
return _ref17.apply(this, arguments);
|
|
968
818
|
};
|
|
969
819
|
}();
|
|
970
|
-
|
|
971
820
|
exports.FinalizeUploadJob = /*#__PURE__*/function () {
|
|
972
821
|
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref18) {
|
|
973
822
|
var libraryId, objectId, writeToken, path;
|
|
974
823
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
975
|
-
while (1) {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
_context11.
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
case 13:
|
|
1008
|
-
case "end":
|
|
1009
|
-
return _context11.stop();
|
|
1010
|
-
}
|
|
824
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
825
|
+
case 0:
|
|
826
|
+
libraryId = _ref18.libraryId, objectId = _ref18.objectId, writeToken = _ref18.writeToken;
|
|
827
|
+
ValidateParameters({
|
|
828
|
+
libraryId: libraryId,
|
|
829
|
+
objectId: objectId
|
|
830
|
+
});
|
|
831
|
+
ValidateWriteToken(writeToken);
|
|
832
|
+
this.Log("Finalizing upload job: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
833
|
+
path = UrlJoin("q", writeToken, "files");
|
|
834
|
+
_context11.t0 = this.HttpClient;
|
|
835
|
+
_context11.t1 = path;
|
|
836
|
+
_context11.next = 9;
|
|
837
|
+
return this.authClient.AuthorizationHeader({
|
|
838
|
+
libraryId: libraryId,
|
|
839
|
+
objectId: objectId,
|
|
840
|
+
update: true
|
|
841
|
+
});
|
|
842
|
+
case 9:
|
|
843
|
+
_context11.t2 = _context11.sent;
|
|
844
|
+
_context11.t3 = {
|
|
845
|
+
method: "POST",
|
|
846
|
+
path: _context11.t1,
|
|
847
|
+
bodyType: "BINARY",
|
|
848
|
+
headers: _context11.t2,
|
|
849
|
+
failover: false
|
|
850
|
+
};
|
|
851
|
+
_context11.next = 13;
|
|
852
|
+
return _context11.t0.Request.call(_context11.t0, _context11.t3);
|
|
853
|
+
case 13:
|
|
854
|
+
case "end":
|
|
855
|
+
return _context11.stop();
|
|
1011
856
|
}
|
|
1012
857
|
}, _callee11, this);
|
|
1013
858
|
}));
|
|
1014
|
-
|
|
1015
859
|
return function (_x12) {
|
|
1016
860
|
return _ref19.apply(this, arguments);
|
|
1017
861
|
};
|
|
1018
862
|
}();
|
|
863
|
+
|
|
1019
864
|
/**
|
|
1020
865
|
* Create the specified directories on the specified object
|
|
1021
866
|
*
|
|
@@ -1027,50 +872,45 @@ exports.FinalizeUploadJob = /*#__PURE__*/function () {
|
|
|
1027
872
|
* @param {string} writeToken - Write token of the draft
|
|
1028
873
|
* @param {Array<string>} filePaths - List of file paths to create
|
|
1029
874
|
*/
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
875
|
exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
1033
876
|
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref20) {
|
|
1034
877
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1035
878
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1036
|
-
while (1) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
case "end":
|
|
1064
|
-
return _context12.stop();
|
|
1065
|
-
}
|
|
879
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
880
|
+
case 0:
|
|
881
|
+
libraryId = _ref20.libraryId, objectId = _ref20.objectId, writeToken = _ref20.writeToken, filePaths = _ref20.filePaths;
|
|
882
|
+
ValidateParameters({
|
|
883
|
+
libraryId: libraryId,
|
|
884
|
+
objectId: objectId
|
|
885
|
+
});
|
|
886
|
+
ValidateWriteToken(writeToken);
|
|
887
|
+
this.Log("Creating Directories: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
888
|
+
this.Log(filePaths);
|
|
889
|
+
ops = filePaths.map(function (path) {
|
|
890
|
+
return {
|
|
891
|
+
op: "add",
|
|
892
|
+
type: "directory",
|
|
893
|
+
path: path
|
|
894
|
+
};
|
|
895
|
+
});
|
|
896
|
+
_context12.next = 8;
|
|
897
|
+
return this.CreateFileUploadJob({
|
|
898
|
+
libraryId: libraryId,
|
|
899
|
+
objectId: objectId,
|
|
900
|
+
writeToken: writeToken,
|
|
901
|
+
ops: ops
|
|
902
|
+
});
|
|
903
|
+
case 8:
|
|
904
|
+
case "end":
|
|
905
|
+
return _context12.stop();
|
|
1066
906
|
}
|
|
1067
907
|
}, _callee12, this);
|
|
1068
908
|
}));
|
|
1069
|
-
|
|
1070
909
|
return function (_x13) {
|
|
1071
910
|
return _ref21.apply(this, arguments);
|
|
1072
911
|
};
|
|
1073
912
|
}();
|
|
913
|
+
|
|
1074
914
|
/**
|
|
1075
915
|
* Delete the specified list of files/directories
|
|
1076
916
|
*
|
|
@@ -1082,49 +922,44 @@ exports.CreateFileDirectories = /*#__PURE__*/function () {
|
|
|
1082
922
|
* @param {string} writeToken - Write token of the draft
|
|
1083
923
|
* @param {Array<string>} filePaths - List of file paths to delete
|
|
1084
924
|
*/
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
925
|
exports.DeleteFiles = /*#__PURE__*/function () {
|
|
1088
926
|
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref22) {
|
|
1089
927
|
var libraryId, objectId, writeToken, filePaths, ops;
|
|
1090
928
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1091
|
-
while (1) {
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
case "end":
|
|
1118
|
-
return _context13.stop();
|
|
1119
|
-
}
|
|
929
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
930
|
+
case 0:
|
|
931
|
+
libraryId = _ref22.libraryId, objectId = _ref22.objectId, writeToken = _ref22.writeToken, filePaths = _ref22.filePaths;
|
|
932
|
+
ValidateParameters({
|
|
933
|
+
libraryId: libraryId,
|
|
934
|
+
objectId: objectId
|
|
935
|
+
});
|
|
936
|
+
ValidateWriteToken(writeToken);
|
|
937
|
+
this.Log("Deleting Files: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
938
|
+
this.Log(filePaths);
|
|
939
|
+
ops = filePaths.map(function (path) {
|
|
940
|
+
return {
|
|
941
|
+
op: "del",
|
|
942
|
+
path: path
|
|
943
|
+
};
|
|
944
|
+
});
|
|
945
|
+
_context13.next = 8;
|
|
946
|
+
return this.CreateFileUploadJob({
|
|
947
|
+
libraryId: libraryId,
|
|
948
|
+
objectId: objectId,
|
|
949
|
+
writeToken: writeToken,
|
|
950
|
+
ops: ops
|
|
951
|
+
});
|
|
952
|
+
case 8:
|
|
953
|
+
case "end":
|
|
954
|
+
return _context13.stop();
|
|
1120
955
|
}
|
|
1121
956
|
}, _callee13, this);
|
|
1122
957
|
}));
|
|
1123
|
-
|
|
1124
958
|
return function (_x14) {
|
|
1125
959
|
return _ref23.apply(this, arguments);
|
|
1126
960
|
};
|
|
1127
961
|
}();
|
|
962
|
+
|
|
1128
963
|
/**
|
|
1129
964
|
* Download a file from a content object
|
|
1130
965
|
*
|
|
@@ -1138,229 +973,198 @@ exports.DeleteFiles = /*#__PURE__*/function () {
|
|
|
1138
973
|
* @param {string} filePath - Path to the file to download
|
|
1139
974
|
* @param {string=} format="blob" - Format in which to return the data ("blob" | "arraybuffer" | "buffer)
|
|
1140
975
|
* @param {boolean=} chunked=false - If specified, file will be downloaded and decrypted in chunks. The
|
|
1141
|
-
* specified callback will be invoked on completion of each chunk. This is recommended for large files.
|
|
1142
|
-
* @param {number=} chunkSize=1000000 - Size of file chunks to request for download
|
|
1143
|
-
* - NOTE: If the file is encrypted, the size of the chunks returned via the callback function will not be affected by this value
|
|
1144
|
-
* @param {boolean=} clientSideDecryption=false - If specified, decryption of the file (if necessary) will be done by the client
|
|
1145
|
-
* instead of on the fabric node
|
|
1146
|
-
* @param {function=} callback - If specified, will be periodically called with current download status - Required if `chunked` is true
|
|
1147
|
-
* - Signature: ({bytesFinished, bytesTotal}) => {}
|
|
1148
|
-
* - Signature (chunked): ({bytesFinished, bytesTotal, chunk}) => {}
|
|
1149
|
-
*
|
|
1150
|
-
* @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, file data in the requested format otherwise
|
|
1151
|
-
*/
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
encryption
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
_context14.next =
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
_context14.
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
_context14.
|
|
1283
|
-
_context14.
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
bytesTotal: bytesTotal,
|
|
1326
|
-
headers: headers,
|
|
1327
|
-
callback: callback,
|
|
1328
|
-
format: format,
|
|
1329
|
-
chunked: chunked,
|
|
1330
|
-
chunkSize: chunkSize
|
|
1331
|
-
});
|
|
1332
|
-
|
|
1333
|
-
case 55:
|
|
1334
|
-
return _context14.abrupt("return", _context14.sent);
|
|
1335
|
-
|
|
1336
|
-
case 58:
|
|
1337
|
-
_context14.prev = 58;
|
|
1338
|
-
_context14.t15 = _context14["catch"](52);
|
|
1339
|
-
|
|
1340
|
-
if (!(encrypted && !clientSideDecryption)) {
|
|
1341
|
-
_context14.next = 62;
|
|
1342
|
-
break;
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
return _context14.abrupt("return", this.DownloadFile(_objectSpread(_objectSpread({}, _args14[0]), {}, {
|
|
1346
|
-
clientSideDecryption: true
|
|
1347
|
-
})));
|
|
1348
|
-
|
|
1349
|
-
case 62:
|
|
1350
|
-
throw _context14.t15;
|
|
1351
|
-
|
|
1352
|
-
case 63:
|
|
1353
|
-
case "end":
|
|
1354
|
-
return _context14.stop();
|
|
1355
|
-
}
|
|
976
|
+
* specified callback will be invoked on completion of each chunk. This is recommended for large files.
|
|
977
|
+
* @param {number=} chunkSize=1000000 - Size of file chunks to request for download
|
|
978
|
+
* - NOTE: If the file is encrypted, the size of the chunks returned via the callback function will not be affected by this value
|
|
979
|
+
* @param {boolean=} clientSideDecryption=false - If specified, decryption of the file (if necessary) will be done by the client
|
|
980
|
+
* instead of on the fabric node
|
|
981
|
+
* @param {function=} callback - If specified, will be periodically called with current download status - Required if `chunked` is true
|
|
982
|
+
* - Signature: ({bytesFinished, bytesTotal}) => {}
|
|
983
|
+
* - Signature (chunked): ({bytesFinished, bytesTotal, chunk}) => {}
|
|
984
|
+
*
|
|
985
|
+
* @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, file data in the requested format otherwise
|
|
986
|
+
*/
|
|
987
|
+
exports.DownloadFile = /*#__PURE__*/function () {
|
|
988
|
+
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref24) {
|
|
989
|
+
var libraryId,
|
|
990
|
+
objectId,
|
|
991
|
+
versionHash,
|
|
992
|
+
writeToken,
|
|
993
|
+
filePath,
|
|
994
|
+
_ref24$format,
|
|
995
|
+
format,
|
|
996
|
+
_ref24$chunked,
|
|
997
|
+
chunked,
|
|
998
|
+
chunkSize,
|
|
999
|
+
_ref24$clientSideDecr,
|
|
1000
|
+
clientSideDecryption,
|
|
1001
|
+
callback,
|
|
1002
|
+
fileInfo,
|
|
1003
|
+
encrypted,
|
|
1004
|
+
encryption,
|
|
1005
|
+
path,
|
|
1006
|
+
headers,
|
|
1007
|
+
ownerCapKey,
|
|
1008
|
+
ownerCap,
|
|
1009
|
+
bytesTotal,
|
|
1010
|
+
_args14 = arguments;
|
|
1011
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1012
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1013
|
+
case 0:
|
|
1014
|
+
libraryId = _ref24.libraryId, objectId = _ref24.objectId, versionHash = _ref24.versionHash, writeToken = _ref24.writeToken, filePath = _ref24.filePath, _ref24$format = _ref24.format, format = _ref24$format === void 0 ? "arrayBuffer" : _ref24$format, _ref24$chunked = _ref24.chunked, chunked = _ref24$chunked === void 0 ? false : _ref24$chunked, chunkSize = _ref24.chunkSize, _ref24$clientSideDecr = _ref24.clientSideDecryption, clientSideDecryption = _ref24$clientSideDecr === void 0 ? false : _ref24$clientSideDecr, callback = _ref24.callback;
|
|
1015
|
+
ValidateParameters({
|
|
1016
|
+
libraryId: libraryId,
|
|
1017
|
+
objectId: objectId,
|
|
1018
|
+
versionHash: versionHash
|
|
1019
|
+
});
|
|
1020
|
+
ValidatePresence("filePath", filePath);
|
|
1021
|
+
if (versionHash) {
|
|
1022
|
+
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1023
|
+
}
|
|
1024
|
+
_context14.next = 6;
|
|
1025
|
+
return this.ContentObjectMetadata({
|
|
1026
|
+
libraryId: libraryId,
|
|
1027
|
+
objectId: objectId,
|
|
1028
|
+
versionHash: versionHash,
|
|
1029
|
+
writeToken: writeToken,
|
|
1030
|
+
metadataSubtree: UrlJoin("files", filePath)
|
|
1031
|
+
});
|
|
1032
|
+
case 6:
|
|
1033
|
+
fileInfo = _context14.sent;
|
|
1034
|
+
encrypted = fileInfo && fileInfo["."].encryption && fileInfo["."].encryption.scheme === "cgck";
|
|
1035
|
+
encryption = encrypted ? "cgck" : undefined;
|
|
1036
|
+
path = encrypted && !clientSideDecryption ? UrlJoin("q", writeToken || versionHash || objectId, "rep", "files_download", filePath) : UrlJoin("q", writeToken || versionHash || objectId, "files", filePath);
|
|
1037
|
+
_context14.next = 12;
|
|
1038
|
+
return this.authClient.AuthorizationHeader({
|
|
1039
|
+
libraryId: libraryId,
|
|
1040
|
+
objectId: objectId,
|
|
1041
|
+
versionHash: versionHash,
|
|
1042
|
+
encryption: encryption
|
|
1043
|
+
});
|
|
1044
|
+
case 12:
|
|
1045
|
+
headers = _context14.sent;
|
|
1046
|
+
headers.Accept = "*/*";
|
|
1047
|
+
|
|
1048
|
+
// If not owner, indicate re-encryption
|
|
1049
|
+
ownerCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
|
|
1050
|
+
_context14.next = 17;
|
|
1051
|
+
return this.ContentObjectMetadata({
|
|
1052
|
+
libraryId: libraryId,
|
|
1053
|
+
objectId: objectId,
|
|
1054
|
+
metadataSubtree: ownerCapKey
|
|
1055
|
+
});
|
|
1056
|
+
case 17:
|
|
1057
|
+
ownerCap = _context14.sent;
|
|
1058
|
+
_context14.t1 = encrypted;
|
|
1059
|
+
if (!_context14.t1) {
|
|
1060
|
+
_context14.next = 26;
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
_context14.t2 = this.utils;
|
|
1064
|
+
_context14.t3 = this.signer.address;
|
|
1065
|
+
_context14.next = 24;
|
|
1066
|
+
return this.ContentObjectOwner({
|
|
1067
|
+
objectId: objectId
|
|
1068
|
+
});
|
|
1069
|
+
case 24:
|
|
1070
|
+
_context14.t4 = _context14.sent;
|
|
1071
|
+
_context14.t1 = !_context14.t2.EqualAddress.call(_context14.t2, _context14.t3, _context14.t4);
|
|
1072
|
+
case 26:
|
|
1073
|
+
_context14.t0 = _context14.t1;
|
|
1074
|
+
if (!_context14.t0) {
|
|
1075
|
+
_context14.next = 29;
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
_context14.t0 = !ownerCap;
|
|
1079
|
+
case 29:
|
|
1080
|
+
if (!_context14.t0) {
|
|
1081
|
+
_context14.next = 31;
|
|
1082
|
+
break;
|
|
1083
|
+
}
|
|
1084
|
+
headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
|
|
1085
|
+
case 31:
|
|
1086
|
+
// If using server side decryption, specify in header
|
|
1087
|
+
if (encrypted && !clientSideDecryption) {
|
|
1088
|
+
headers["X-Content-Fabric-Decryption-Mode"] = "decrypt";
|
|
1089
|
+
// rep/files_download endpoint doesn't currently support Range header
|
|
1090
|
+
chunkSize = Number.MAX_SAFE_INTEGER;
|
|
1091
|
+
}
|
|
1092
|
+
bytesTotal = fileInfo["."].size;
|
|
1093
|
+
if (!(encrypted && clientSideDecryption)) {
|
|
1094
|
+
_context14.next = 51;
|
|
1095
|
+
break;
|
|
1096
|
+
}
|
|
1097
|
+
_context14.t5 = this;
|
|
1098
|
+
_context14.next = 37;
|
|
1099
|
+
return this.EncryptionConk({
|
|
1100
|
+
libraryId: libraryId,
|
|
1101
|
+
objectId: objectId,
|
|
1102
|
+
versionHash: versionHash,
|
|
1103
|
+
download: true
|
|
1104
|
+
});
|
|
1105
|
+
case 37:
|
|
1106
|
+
_context14.t6 = _context14.sent;
|
|
1107
|
+
_context14.t7 = path;
|
|
1108
|
+
_context14.t8 = bytesTotal;
|
|
1109
|
+
_context14.t9 = headers;
|
|
1110
|
+
_context14.t10 = callback;
|
|
1111
|
+
_context14.t11 = format;
|
|
1112
|
+
_context14.t12 = clientSideDecryption;
|
|
1113
|
+
_context14.t13 = chunked;
|
|
1114
|
+
_context14.t14 = {
|
|
1115
|
+
conk: _context14.t6,
|
|
1116
|
+
downloadPath: _context14.t7,
|
|
1117
|
+
bytesTotal: _context14.t8,
|
|
1118
|
+
headers: _context14.t9,
|
|
1119
|
+
callback: _context14.t10,
|
|
1120
|
+
format: _context14.t11,
|
|
1121
|
+
clientSideDecryption: _context14.t12,
|
|
1122
|
+
chunked: _context14.t13
|
|
1123
|
+
};
|
|
1124
|
+
_context14.next = 48;
|
|
1125
|
+
return _context14.t5.DownloadEncrypted.call(_context14.t5, _context14.t14);
|
|
1126
|
+
case 48:
|
|
1127
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1128
|
+
case 51:
|
|
1129
|
+
if (!chunkSize) {
|
|
1130
|
+
chunkSize = 10000000;
|
|
1131
|
+
}
|
|
1132
|
+
_context14.prev = 52;
|
|
1133
|
+
_context14.next = 55;
|
|
1134
|
+
return this.Download({
|
|
1135
|
+
downloadPath: path,
|
|
1136
|
+
bytesTotal: bytesTotal,
|
|
1137
|
+
headers: headers,
|
|
1138
|
+
callback: callback,
|
|
1139
|
+
format: format,
|
|
1140
|
+
chunked: chunked,
|
|
1141
|
+
chunkSize: chunkSize
|
|
1142
|
+
});
|
|
1143
|
+
case 55:
|
|
1144
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1145
|
+
case 58:
|
|
1146
|
+
_context14.prev = 58;
|
|
1147
|
+
_context14.t15 = _context14["catch"](52);
|
|
1148
|
+
if (!(encrypted && !clientSideDecryption)) {
|
|
1149
|
+
_context14.next = 62;
|
|
1150
|
+
break;
|
|
1151
|
+
}
|
|
1152
|
+
return _context14.abrupt("return", this.DownloadFile(_objectSpread(_objectSpread({}, _args14[0]), {}, {
|
|
1153
|
+
clientSideDecryption: true
|
|
1154
|
+
})));
|
|
1155
|
+
case 62:
|
|
1156
|
+
throw _context14.t15;
|
|
1157
|
+
case 63:
|
|
1158
|
+
case "end":
|
|
1159
|
+
return _context14.stop();
|
|
1356
1160
|
}
|
|
1357
1161
|
}, _callee14, this, [[52, 58]]);
|
|
1358
1162
|
}));
|
|
1359
|
-
|
|
1360
1163
|
return function (_x15) {
|
|
1361
1164
|
return _ref25.apply(this, arguments);
|
|
1362
1165
|
};
|
|
1363
1166
|
}();
|
|
1167
|
+
|
|
1364
1168
|
/* Parts */
|
|
1365
1169
|
|
|
1366
1170
|
/**
|
|
@@ -1375,65 +1179,56 @@ exports.DownloadFile = /*#__PURE__*/function () {
|
|
|
1375
1179
|
*
|
|
1376
1180
|
* @returns {Promise<Object>} - Response containing list of parts of the object
|
|
1377
1181
|
*/
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
1182
|
exports.ContentParts = /*#__PURE__*/function () {
|
|
1381
1183
|
var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref26) {
|
|
1382
1184
|
var libraryId, objectId, versionHash, path, response;
|
|
1383
1185
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1384
|
-
while (1) {
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
_context15.t3
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
response = _context15.sent;
|
|
1423
|
-
return _context15.abrupt("return", response.parts);
|
|
1424
|
-
|
|
1425
|
-
case 17:
|
|
1426
|
-
case "end":
|
|
1427
|
-
return _context15.stop();
|
|
1428
|
-
}
|
|
1186
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1187
|
+
case 0:
|
|
1188
|
+
libraryId = _ref26.libraryId, objectId = _ref26.objectId, versionHash = _ref26.versionHash;
|
|
1189
|
+
ValidateParameters({
|
|
1190
|
+
libraryId: libraryId,
|
|
1191
|
+
objectId: objectId,
|
|
1192
|
+
versionHash: versionHash
|
|
1193
|
+
});
|
|
1194
|
+
this.Log("Retrieving parts: ".concat(libraryId, " ").concat(objectId || versionHash));
|
|
1195
|
+
if (versionHash) {
|
|
1196
|
+
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1197
|
+
}
|
|
1198
|
+
path = UrlJoin("q", versionHash || objectId, "parts");
|
|
1199
|
+
_context15.t0 = this.utils;
|
|
1200
|
+
_context15.t1 = this.HttpClient;
|
|
1201
|
+
_context15.next = 9;
|
|
1202
|
+
return this.authClient.AuthorizationHeader({
|
|
1203
|
+
libraryId: libraryId,
|
|
1204
|
+
objectId: objectId,
|
|
1205
|
+
versionHash: versionHash
|
|
1206
|
+
});
|
|
1207
|
+
case 9:
|
|
1208
|
+
_context15.t2 = _context15.sent;
|
|
1209
|
+
_context15.t3 = path;
|
|
1210
|
+
_context15.t4 = {
|
|
1211
|
+
headers: _context15.t2,
|
|
1212
|
+
method: "GET",
|
|
1213
|
+
path: _context15.t3
|
|
1214
|
+
};
|
|
1215
|
+
_context15.t5 = _context15.t1.Request.call(_context15.t1, _context15.t4);
|
|
1216
|
+
_context15.next = 15;
|
|
1217
|
+
return _context15.t0.ResponseToJson.call(_context15.t0, _context15.t5);
|
|
1218
|
+
case 15:
|
|
1219
|
+
response = _context15.sent;
|
|
1220
|
+
return _context15.abrupt("return", response.parts);
|
|
1221
|
+
case 17:
|
|
1222
|
+
case "end":
|
|
1223
|
+
return _context15.stop();
|
|
1429
1224
|
}
|
|
1430
1225
|
}, _callee15, this);
|
|
1431
1226
|
}));
|
|
1432
|
-
|
|
1433
1227
|
return function (_x16) {
|
|
1434
1228
|
return _ref27.apply(this, arguments);
|
|
1435
1229
|
};
|
|
1436
1230
|
}();
|
|
1231
|
+
|
|
1437
1232
|
/**
|
|
1438
1233
|
* Get information on a specific part
|
|
1439
1234
|
*
|
|
@@ -1447,65 +1242,56 @@ exports.ContentParts = /*#__PURE__*/function () {
|
|
|
1447
1242
|
*
|
|
1448
1243
|
* @returns {Promise<Object>} - Response containing information about the specified part
|
|
1449
1244
|
*/
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
1245
|
exports.ContentPart = /*#__PURE__*/function () {
|
|
1453
1246
|
var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref28) {
|
|
1454
1247
|
var libraryId, objectId, versionHash, partHash, path;
|
|
1455
1248
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1456
|
-
while (1) {
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
_context16.t3
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
case 16:
|
|
1495
|
-
return _context16.abrupt("return", _context16.sent);
|
|
1496
|
-
|
|
1497
|
-
case 17:
|
|
1498
|
-
case "end":
|
|
1499
|
-
return _context16.stop();
|
|
1500
|
-
}
|
|
1249
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1250
|
+
case 0:
|
|
1251
|
+
libraryId = _ref28.libraryId, objectId = _ref28.objectId, versionHash = _ref28.versionHash, partHash = _ref28.partHash;
|
|
1252
|
+
ValidateParameters({
|
|
1253
|
+
libraryId: libraryId,
|
|
1254
|
+
objectId: objectId,
|
|
1255
|
+
versionHash: versionHash
|
|
1256
|
+
});
|
|
1257
|
+
ValidatePartHash(partHash);
|
|
1258
|
+
this.Log("Retrieving part: ".concat(libraryId, " ").concat(objectId || versionHash, " ").concat(partHash));
|
|
1259
|
+
if (versionHash) {
|
|
1260
|
+
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1261
|
+
}
|
|
1262
|
+
path = UrlJoin("q", versionHash || objectId, "parts", partHash);
|
|
1263
|
+
_context16.t0 = this.utils;
|
|
1264
|
+
_context16.t1 = this.HttpClient;
|
|
1265
|
+
_context16.next = 10;
|
|
1266
|
+
return this.authClient.AuthorizationHeader({
|
|
1267
|
+
libraryId: libraryId,
|
|
1268
|
+
objectId: objectId,
|
|
1269
|
+
versionHash: versionHash
|
|
1270
|
+
});
|
|
1271
|
+
case 10:
|
|
1272
|
+
_context16.t2 = _context16.sent;
|
|
1273
|
+
_context16.t3 = path;
|
|
1274
|
+
_context16.t4 = {
|
|
1275
|
+
headers: _context16.t2,
|
|
1276
|
+
method: "GET",
|
|
1277
|
+
path: _context16.t3
|
|
1278
|
+
};
|
|
1279
|
+
_context16.t5 = _context16.t1.Request.call(_context16.t1, _context16.t4);
|
|
1280
|
+
_context16.next = 16;
|
|
1281
|
+
return _context16.t0.ResponseToJson.call(_context16.t0, _context16.t5);
|
|
1282
|
+
case 16:
|
|
1283
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1284
|
+
case 17:
|
|
1285
|
+
case "end":
|
|
1286
|
+
return _context16.stop();
|
|
1501
1287
|
}
|
|
1502
1288
|
}, _callee16, this);
|
|
1503
1289
|
}));
|
|
1504
|
-
|
|
1505
1290
|
return function (_x17) {
|
|
1506
1291
|
return _ref29.apply(this, arguments);
|
|
1507
1292
|
};
|
|
1508
1293
|
}();
|
|
1294
|
+
|
|
1509
1295
|
/**
|
|
1510
1296
|
* Download a part from a content object. The fromByte and range parameters can be used to specify a
|
|
1511
1297
|
* specific section of the part to download.
|
|
@@ -1530,419 +1316,341 @@ exports.ContentPart = /*#__PURE__*/function () {
|
|
|
1530
1316
|
*
|
|
1531
1317
|
* @returns {Promise<ArrayBuffer> | undefined} - No return if chunked is specified, part data in the requested format otherwise
|
|
1532
1318
|
*/
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
1319
|
exports.DownloadPart = /*#__PURE__*/function () {
|
|
1536
1320
|
var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref30) {
|
|
1537
1321
|
var libraryId, objectId, versionHash, writeToken, partHash, _ref30$format, format, _ref30$chunked, chunked, _ref30$chunkSize, chunkSize, callback, encrypted, encryption, path, headers, bytesTotal;
|
|
1538
|
-
|
|
1539
1322
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1540
|
-
while (1) {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
_context17.next =
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
_context17.
|
|
1614
|
-
_context17.
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
return this.Download({
|
|
1637
|
-
downloadPath: path,
|
|
1638
|
-
bytesTotal: bytesTotal,
|
|
1639
|
-
headers: headers,
|
|
1640
|
-
callback: callback,
|
|
1641
|
-
format: format,
|
|
1642
|
-
chunked: chunked,
|
|
1643
|
-
chunkSize: chunkSize
|
|
1644
|
-
});
|
|
1645
|
-
|
|
1646
|
-
case 39:
|
|
1647
|
-
return _context17.abrupt("return", _context17.sent);
|
|
1648
|
-
|
|
1649
|
-
case 40:
|
|
1650
|
-
case "end":
|
|
1651
|
-
return _context17.stop();
|
|
1652
|
-
}
|
|
1323
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1324
|
+
case 0:
|
|
1325
|
+
libraryId = _ref30.libraryId, objectId = _ref30.objectId, versionHash = _ref30.versionHash, writeToken = _ref30.writeToken, partHash = _ref30.partHash, _ref30$format = _ref30.format, format = _ref30$format === void 0 ? "arrayBuffer" : _ref30$format, _ref30$chunked = _ref30.chunked, chunked = _ref30$chunked === void 0 ? false : _ref30$chunked, _ref30$chunkSize = _ref30.chunkSize, chunkSize = _ref30$chunkSize === void 0 ? 10000000 : _ref30$chunkSize, callback = _ref30.callback;
|
|
1326
|
+
ValidateParameters({
|
|
1327
|
+
libraryId: libraryId,
|
|
1328
|
+
objectId: objectId,
|
|
1329
|
+
versionHash: versionHash
|
|
1330
|
+
});
|
|
1331
|
+
ValidatePartHash(partHash);
|
|
1332
|
+
if (versionHash) {
|
|
1333
|
+
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1334
|
+
}
|
|
1335
|
+
encrypted = partHash.startsWith("hqpe");
|
|
1336
|
+
encryption = encrypted ? "cgck" : undefined;
|
|
1337
|
+
path = UrlJoin("q", writeToken || versionHash || objectId, "data", partHash);
|
|
1338
|
+
_context17.next = 9;
|
|
1339
|
+
return this.authClient.AuthorizationHeader({
|
|
1340
|
+
libraryId: libraryId,
|
|
1341
|
+
objectId: objectId,
|
|
1342
|
+
versionHash: versionHash,
|
|
1343
|
+
encryption: encryption,
|
|
1344
|
+
makeAccessRequest: true
|
|
1345
|
+
});
|
|
1346
|
+
case 9:
|
|
1347
|
+
headers = _context17.sent;
|
|
1348
|
+
_context17.next = 12;
|
|
1349
|
+
return this.ContentPart({
|
|
1350
|
+
libraryId: libraryId,
|
|
1351
|
+
objectId: objectId,
|
|
1352
|
+
versionHash: versionHash,
|
|
1353
|
+
partHash: partHash
|
|
1354
|
+
});
|
|
1355
|
+
case 12:
|
|
1356
|
+
bytesTotal = _context17.sent.part.size;
|
|
1357
|
+
if (!encrypted) {
|
|
1358
|
+
_context17.next = 37;
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
_context17.t0 = this.utils;
|
|
1362
|
+
_context17.t1 = this.signer.address;
|
|
1363
|
+
_context17.next = 18;
|
|
1364
|
+
return this.ContentObjectOwner({
|
|
1365
|
+
objectId: objectId
|
|
1366
|
+
});
|
|
1367
|
+
case 18:
|
|
1368
|
+
_context17.t2 = _context17.sent;
|
|
1369
|
+
if (_context17.t0.EqualAddress.call(_context17.t0, _context17.t1, _context17.t2)) {
|
|
1370
|
+
_context17.next = 21;
|
|
1371
|
+
break;
|
|
1372
|
+
}
|
|
1373
|
+
headers["X-Content-Fabric-Decryption-Mode"] = "reencrypt";
|
|
1374
|
+
case 21:
|
|
1375
|
+
_context17.t3 = this;
|
|
1376
|
+
_context17.next = 24;
|
|
1377
|
+
return this.EncryptionConk({
|
|
1378
|
+
libraryId: libraryId,
|
|
1379
|
+
objectId: objectId,
|
|
1380
|
+
download: true
|
|
1381
|
+
});
|
|
1382
|
+
case 24:
|
|
1383
|
+
_context17.t4 = _context17.sent;
|
|
1384
|
+
_context17.t5 = path;
|
|
1385
|
+
_context17.t6 = bytesTotal;
|
|
1386
|
+
_context17.t7 = headers;
|
|
1387
|
+
_context17.t8 = callback;
|
|
1388
|
+
_context17.t9 = format;
|
|
1389
|
+
_context17.t10 = chunked;
|
|
1390
|
+
_context17.t11 = {
|
|
1391
|
+
conk: _context17.t4,
|
|
1392
|
+
downloadPath: _context17.t5,
|
|
1393
|
+
bytesTotal: _context17.t6,
|
|
1394
|
+
headers: _context17.t7,
|
|
1395
|
+
callback: _context17.t8,
|
|
1396
|
+
format: _context17.t9,
|
|
1397
|
+
chunked: _context17.t10
|
|
1398
|
+
};
|
|
1399
|
+
_context17.next = 34;
|
|
1400
|
+
return _context17.t3.DownloadEncrypted.call(_context17.t3, _context17.t11);
|
|
1401
|
+
case 34:
|
|
1402
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1403
|
+
case 37:
|
|
1404
|
+
_context17.next = 39;
|
|
1405
|
+
return this.Download({
|
|
1406
|
+
downloadPath: path,
|
|
1407
|
+
bytesTotal: bytesTotal,
|
|
1408
|
+
headers: headers,
|
|
1409
|
+
callback: callback,
|
|
1410
|
+
format: format,
|
|
1411
|
+
chunked: chunked,
|
|
1412
|
+
chunkSize: chunkSize
|
|
1413
|
+
});
|
|
1414
|
+
case 39:
|
|
1415
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1416
|
+
case 40:
|
|
1417
|
+
case "end":
|
|
1418
|
+
return _context17.stop();
|
|
1653
1419
|
}
|
|
1654
1420
|
}, _callee17, this);
|
|
1655
1421
|
}));
|
|
1656
|
-
|
|
1657
1422
|
return function (_x18) {
|
|
1658
1423
|
return _ref31.apply(this, arguments);
|
|
1659
1424
|
};
|
|
1660
1425
|
}();
|
|
1661
|
-
|
|
1662
1426
|
exports.Download = /*#__PURE__*/function () {
|
|
1663
1427
|
var _ref33 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref32) {
|
|
1664
1428
|
var downloadPath, headers, bytesTotal, _ref32$chunked, chunked, _ref32$chunkSize, chunkSize, callback, _ref32$format, format, outputChunks, bytesFinished, totalChunks, i, response;
|
|
1665
|
-
|
|
1666
1429
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1667
|
-
while (1) {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
if (!(chunked && !callback)) {
|
|
1673
|
-
_context18.next = 3;
|
|
1674
|
-
break;
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
throw Error("No callback specified for chunked download");
|
|
1678
|
-
|
|
1679
|
-
case 3:
|
|
1680
|
-
if (!chunked) {
|
|
1681
|
-
outputChunks = [];
|
|
1682
|
-
} // Download file in chunks
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
bytesFinished = 0;
|
|
1686
|
-
totalChunks = Math.ceil(bytesTotal / chunkSize);
|
|
1687
|
-
i = 0;
|
|
1688
|
-
|
|
1689
|
-
case 7:
|
|
1690
|
-
if (!(i < totalChunks)) {
|
|
1691
|
-
_context18.next = 35;
|
|
1692
|
-
break;
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
1696
|
-
_context18.next = 11;
|
|
1697
|
-
return this.HttpClient.Request({
|
|
1698
|
-
path: downloadPath,
|
|
1699
|
-
headers: headers,
|
|
1700
|
-
method: "GET"
|
|
1701
|
-
});
|
|
1702
|
-
|
|
1703
|
-
case 11:
|
|
1704
|
-
response = _context18.sent;
|
|
1705
|
-
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
1706
|
-
|
|
1707
|
-
if (!chunked) {
|
|
1708
|
-
_context18.next = 24;
|
|
1709
|
-
break;
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
_context18.t0 = callback;
|
|
1713
|
-
_context18.t1 = bytesFinished;
|
|
1714
|
-
_context18.t2 = bytesTotal;
|
|
1715
|
-
_context18.next = 19;
|
|
1716
|
-
return this.utils.ResponseToFormat(format, response);
|
|
1717
|
-
|
|
1718
|
-
case 19:
|
|
1719
|
-
_context18.t3 = _context18.sent;
|
|
1720
|
-
_context18.t4 = {
|
|
1721
|
-
bytesFinished: _context18.t1,
|
|
1722
|
-
bytesTotal: _context18.t2,
|
|
1723
|
-
chunk: _context18.t3
|
|
1724
|
-
};
|
|
1725
|
-
(0, _context18.t0)(_context18.t4);
|
|
1726
|
-
_context18.next = 32;
|
|
1430
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1431
|
+
case 0:
|
|
1432
|
+
downloadPath = _ref32.downloadPath, headers = _ref32.headers, bytesTotal = _ref32.bytesTotal, _ref32$chunked = _ref32.chunked, chunked = _ref32$chunked === void 0 ? false : _ref32$chunked, _ref32$chunkSize = _ref32.chunkSize, chunkSize = _ref32$chunkSize === void 0 ? 2000000 : _ref32$chunkSize, callback = _ref32.callback, _ref32$format = _ref32.format, format = _ref32$format === void 0 ? "arrayBuffer" : _ref32$format;
|
|
1433
|
+
if (!(chunked && !callback)) {
|
|
1434
|
+
_context18.next = 3;
|
|
1727
1435
|
break;
|
|
1436
|
+
}
|
|
1437
|
+
throw Error("No callback specified for chunked download");
|
|
1438
|
+
case 3:
|
|
1439
|
+
if (!chunked) {
|
|
1440
|
+
outputChunks = [];
|
|
1441
|
+
}
|
|
1728
1442
|
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
_context18.t7 = _context18.sent;
|
|
1737
|
-
_context18.t8 = _context18.t6.from.call(_context18.t6, _context18.t7);
|
|
1738
|
-
|
|
1739
|
-
_context18.t5.push.call(_context18.t5, _context18.t8);
|
|
1740
|
-
|
|
1741
|
-
if (callback) {
|
|
1742
|
-
callback({
|
|
1743
|
-
bytesFinished: bytesFinished,
|
|
1744
|
-
bytesTotal: bytesTotal
|
|
1745
|
-
});
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
case 32:
|
|
1749
|
-
i++;
|
|
1750
|
-
_context18.next = 7;
|
|
1443
|
+
// Download file in chunks
|
|
1444
|
+
bytesFinished = 0;
|
|
1445
|
+
totalChunks = Math.ceil(bytesTotal / chunkSize);
|
|
1446
|
+
i = 0;
|
|
1447
|
+
case 7:
|
|
1448
|
+
if (!(i < totalChunks)) {
|
|
1449
|
+
_context18.next = 35;
|
|
1751
1450
|
break;
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1451
|
+
}
|
|
1452
|
+
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
1453
|
+
_context18.next = 11;
|
|
1454
|
+
return this.HttpClient.Request({
|
|
1455
|
+
path: downloadPath,
|
|
1456
|
+
headers: headers,
|
|
1457
|
+
method: "GET"
|
|
1458
|
+
});
|
|
1459
|
+
case 11:
|
|
1460
|
+
response = _context18.sent;
|
|
1461
|
+
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
1462
|
+
if (!chunked) {
|
|
1463
|
+
_context18.next = 24;
|
|
1464
|
+
break;
|
|
1465
|
+
}
|
|
1466
|
+
_context18.t0 = callback;
|
|
1467
|
+
_context18.t1 = bytesFinished;
|
|
1468
|
+
_context18.t2 = bytesTotal;
|
|
1469
|
+
_context18.next = 19;
|
|
1470
|
+
return this.utils.ResponseToFormat(format, response);
|
|
1471
|
+
case 19:
|
|
1472
|
+
_context18.t3 = _context18.sent;
|
|
1473
|
+
_context18.t4 = {
|
|
1474
|
+
bytesFinished: _context18.t1,
|
|
1475
|
+
bytesTotal: _context18.t2,
|
|
1476
|
+
chunk: _context18.t3
|
|
1477
|
+
};
|
|
1478
|
+
(0, _context18.t0)(_context18.t4);
|
|
1479
|
+
_context18.next = 32;
|
|
1480
|
+
break;
|
|
1481
|
+
case 24:
|
|
1482
|
+
_context18.t5 = outputChunks;
|
|
1483
|
+
_context18.t6 = Buffer;
|
|
1484
|
+
_context18.next = 28;
|
|
1485
|
+
return response.arrayBuffer();
|
|
1486
|
+
case 28:
|
|
1487
|
+
_context18.t7 = _context18.sent;
|
|
1488
|
+
_context18.t8 = _context18.t6.from.call(_context18.t6, _context18.t7);
|
|
1489
|
+
_context18.t5.push.call(_context18.t5, _context18.t8);
|
|
1490
|
+
if (callback) {
|
|
1491
|
+
callback({
|
|
1492
|
+
bytesFinished: bytesFinished,
|
|
1493
|
+
bytesTotal: bytesTotal
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
case 32:
|
|
1497
|
+
i++;
|
|
1498
|
+
_context18.next = 7;
|
|
1499
|
+
break;
|
|
1500
|
+
case 35:
|
|
1501
|
+
if (chunked) {
|
|
1502
|
+
_context18.next = 39;
|
|
1503
|
+
break;
|
|
1504
|
+
}
|
|
1505
|
+
_context18.next = 38;
|
|
1506
|
+
return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
|
|
1507
|
+
case 38:
|
|
1508
|
+
return _context18.abrupt("return", _context18.sent);
|
|
1509
|
+
case 39:
|
|
1510
|
+
case "end":
|
|
1511
|
+
return _context18.stop();
|
|
1769
1512
|
}
|
|
1770
1513
|
}, _callee18, this);
|
|
1771
1514
|
}));
|
|
1772
|
-
|
|
1773
1515
|
return function (_x19) {
|
|
1774
1516
|
return _ref33.apply(this, arguments);
|
|
1775
1517
|
};
|
|
1776
1518
|
}();
|
|
1777
|
-
|
|
1778
1519
|
exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
1779
1520
|
var _ref35 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref34) {
|
|
1780
1521
|
var _this2 = this;
|
|
1781
|
-
|
|
1782
1522
|
var conk, downloadPath, bytesTotal, headers, callback, _ref34$format, format, _ref34$chunked, chunked, isReencryption, chunkSize, bytesFinished, outputChunks, stream, totalChunks, i, response;
|
|
1783
|
-
|
|
1784
1523
|
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1785
|
-
while (1) {
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1814
|
-
while (1) {
|
|
1815
|
-
switch (_context19.prev = _context19.next) {
|
|
1816
|
-
case 0:
|
|
1817
|
-
if (!chunked) {
|
|
1818
|
-
_context19.next = 13;
|
|
1819
|
-
break;
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
if (!(format !== "buffer")) {
|
|
1823
|
-
_context19.next = 10;
|
|
1824
|
-
break;
|
|
1825
|
-
}
|
|
1826
|
-
|
|
1827
|
-
arrayBuffer = chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength);
|
|
1828
|
-
|
|
1829
|
-
if (!(format === "arraybuffer")) {
|
|
1830
|
-
_context19.next = 7;
|
|
1831
|
-
break;
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
chunk = arrayBuffer;
|
|
1835
|
-
_context19.next = 10;
|
|
1836
|
-
break;
|
|
1837
|
-
|
|
1838
|
-
case 7:
|
|
1839
|
-
_context19.next = 9;
|
|
1840
|
-
return _this2.utils.ResponseToFormat(format, new Response(arrayBuffer));
|
|
1841
|
-
|
|
1842
|
-
case 9:
|
|
1843
|
-
chunk = _context19.sent;
|
|
1844
|
-
|
|
1845
|
-
case 10:
|
|
1846
|
-
callback({
|
|
1847
|
-
bytesFinished: bytesFinished,
|
|
1848
|
-
bytesTotal: bytesTotal,
|
|
1849
|
-
chunk: chunk
|
|
1850
|
-
});
|
|
1851
|
-
_context19.next = 15;
|
|
1852
|
-
break;
|
|
1853
|
-
|
|
1854
|
-
case 13:
|
|
1855
|
-
if (callback) {
|
|
1856
|
-
callback({
|
|
1857
|
-
bytesFinished: bytesFinished,
|
|
1858
|
-
bytesTotal: bytesTotal
|
|
1859
|
-
});
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
outputChunks.push(chunk);
|
|
1863
|
-
|
|
1864
|
-
case 15:
|
|
1865
|
-
case "end":
|
|
1866
|
-
return _context19.stop();
|
|
1524
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1525
|
+
case 0:
|
|
1526
|
+
conk = _ref34.conk, downloadPath = _ref34.downloadPath, bytesTotal = _ref34.bytesTotal, headers = _ref34.headers, callback = _ref34.callback, _ref34$format = _ref34.format, format = _ref34$format === void 0 ? "arrayBuffer" : _ref34$format, _ref34$chunked = _ref34.chunked, chunked = _ref34$chunked === void 0 ? false : _ref34$chunked;
|
|
1527
|
+
if (!(chunked && !callback)) {
|
|
1528
|
+
_context20.next = 3;
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
throw Error("No callback specified for chunked download");
|
|
1532
|
+
case 3:
|
|
1533
|
+
// Must align chunk size with encryption block size
|
|
1534
|
+
isReencryption = conk.public_key.startsWith("ktpk");
|
|
1535
|
+
chunkSize = this.Crypto.EncryptedBlockSize(1000000, isReencryption);
|
|
1536
|
+
bytesFinished = 0;
|
|
1537
|
+
format = format.toLowerCase();
|
|
1538
|
+
outputChunks = []; // Set up decryption stream
|
|
1539
|
+
_context20.next = 10;
|
|
1540
|
+
return this.Crypto.OpenDecryptionStream(conk);
|
|
1541
|
+
case 10:
|
|
1542
|
+
stream = _context20.sent;
|
|
1543
|
+
stream.on("data", /*#__PURE__*/function () {
|
|
1544
|
+
var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(chunk) {
|
|
1545
|
+
var arrayBuffer;
|
|
1546
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1547
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1548
|
+
case 0:
|
|
1549
|
+
if (!chunked) {
|
|
1550
|
+
_context19.next = 13;
|
|
1551
|
+
break;
|
|
1867
1552
|
}
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1553
|
+
if (!(format !== "buffer")) {
|
|
1554
|
+
_context19.next = 10;
|
|
1555
|
+
break;
|
|
1556
|
+
}
|
|
1557
|
+
arrayBuffer = chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength);
|
|
1558
|
+
if (!(format === "arraybuffer")) {
|
|
1559
|
+
_context19.next = 7;
|
|
1560
|
+
break;
|
|
1561
|
+
}
|
|
1562
|
+
chunk = arrayBuffer;
|
|
1563
|
+
_context19.next = 10;
|
|
1564
|
+
break;
|
|
1565
|
+
case 7:
|
|
1566
|
+
_context19.next = 9;
|
|
1567
|
+
return _this2.utils.ResponseToFormat(format, new Response(arrayBuffer));
|
|
1568
|
+
case 9:
|
|
1569
|
+
chunk = _context19.sent;
|
|
1570
|
+
case 10:
|
|
1571
|
+
callback({
|
|
1572
|
+
bytesFinished: bytesFinished,
|
|
1573
|
+
bytesTotal: bytesTotal,
|
|
1574
|
+
chunk: chunk
|
|
1575
|
+
});
|
|
1576
|
+
_context19.next = 15;
|
|
1577
|
+
break;
|
|
1578
|
+
case 13:
|
|
1579
|
+
if (callback) {
|
|
1580
|
+
callback({
|
|
1581
|
+
bytesFinished: bytesFinished,
|
|
1582
|
+
bytesTotal: bytesTotal
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
outputChunks.push(chunk);
|
|
1586
|
+
case 15:
|
|
1587
|
+
case "end":
|
|
1588
|
+
return _context19.stop();
|
|
1589
|
+
}
|
|
1590
|
+
}, _callee19);
|
|
1591
|
+
}));
|
|
1592
|
+
return function (_x21) {
|
|
1593
|
+
return _ref36.apply(this, arguments);
|
|
1594
|
+
};
|
|
1595
|
+
}());
|
|
1596
|
+
totalChunks = Math.ceil(bytesTotal / chunkSize);
|
|
1597
|
+
i = 0;
|
|
1598
|
+
case 14:
|
|
1599
|
+
if (!(i < totalChunks)) {
|
|
1600
|
+
_context20.next = 30;
|
|
1910
1601
|
break;
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1602
|
+
}
|
|
1603
|
+
headers["Range"] = "bytes=".concat(bytesFinished, "-").concat(bytesFinished + chunkSize - 1);
|
|
1604
|
+
_context20.next = 18;
|
|
1605
|
+
return this.HttpClient.Request({
|
|
1606
|
+
headers: headers,
|
|
1607
|
+
method: "GET",
|
|
1608
|
+
path: downloadPath
|
|
1609
|
+
});
|
|
1610
|
+
case 18:
|
|
1611
|
+
response = _context20.sent;
|
|
1612
|
+
bytesFinished = Math.min(bytesFinished + chunkSize, bytesTotal);
|
|
1613
|
+
_context20.t0 = stream;
|
|
1614
|
+
_context20.t1 = Uint8Array;
|
|
1615
|
+
_context20.next = 24;
|
|
1616
|
+
return response.arrayBuffer();
|
|
1617
|
+
case 24:
|
|
1618
|
+
_context20.t2 = _context20.sent;
|
|
1619
|
+
_context20.t3 = new _context20.t1(_context20.t2);
|
|
1620
|
+
_context20.t0.write.call(_context20.t0, _context20.t3);
|
|
1621
|
+
case 27:
|
|
1622
|
+
i++;
|
|
1623
|
+
_context20.next = 14;
|
|
1624
|
+
break;
|
|
1625
|
+
case 30:
|
|
1626
|
+
// Wait for decryption to complete
|
|
1627
|
+
stream.end();
|
|
1628
|
+
_context20.next = 33;
|
|
1629
|
+
return new Promise(function (resolve) {
|
|
1630
|
+
return stream.on("finish", function () {
|
|
1631
|
+
resolve();
|
|
1920
1632
|
});
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
case 37:
|
|
1935
|
-
case "end":
|
|
1936
|
-
return _context20.stop();
|
|
1937
|
-
}
|
|
1633
|
+
});
|
|
1634
|
+
case 33:
|
|
1635
|
+
if (chunked) {
|
|
1636
|
+
_context20.next = 37;
|
|
1637
|
+
break;
|
|
1638
|
+
}
|
|
1639
|
+
_context20.next = 36;
|
|
1640
|
+
return this.utils.ResponseToFormat(format, new Response(Buffer.concat(outputChunks)));
|
|
1641
|
+
case 36:
|
|
1642
|
+
return _context20.abrupt("return", _context20.sent);
|
|
1643
|
+
case 37:
|
|
1644
|
+
case "end":
|
|
1645
|
+
return _context20.stop();
|
|
1938
1646
|
}
|
|
1939
1647
|
}, _callee20, this);
|
|
1940
1648
|
}));
|
|
1941
|
-
|
|
1942
1649
|
return function (_x20) {
|
|
1943
1650
|
return _ref35.apply(this, arguments);
|
|
1944
1651
|
};
|
|
1945
1652
|
}();
|
|
1653
|
+
|
|
1946
1654
|
/**
|
|
1947
1655
|
* Create a part upload draft
|
|
1948
1656
|
*
|
|
@@ -1956,63 +1664,56 @@ exports.DownloadEncrypted = /*#__PURE__*/function () {
|
|
|
1956
1664
|
*
|
|
1957
1665
|
* @returns {Promise<string>} - The part write token for the part draft
|
|
1958
1666
|
*/
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
1667
|
exports.CreatePart = /*#__PURE__*/function () {
|
|
1962
1668
|
var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref37) {
|
|
1963
1669
|
var libraryId, objectId, writeToken, encryption, path, openResponse;
|
|
1964
1670
|
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1965
|
-
while (1) {
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
_context21.
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
case 16:
|
|
2005
|
-
case "end":
|
|
2006
|
-
return _context21.stop();
|
|
2007
|
-
}
|
|
1671
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1672
|
+
case 0:
|
|
1673
|
+
libraryId = _ref37.libraryId, objectId = _ref37.objectId, writeToken = _ref37.writeToken, encryption = _ref37.encryption;
|
|
1674
|
+
ValidateParameters({
|
|
1675
|
+
libraryId: libraryId,
|
|
1676
|
+
objectId: objectId
|
|
1677
|
+
});
|
|
1678
|
+
ValidateWriteToken(writeToken);
|
|
1679
|
+
path = UrlJoin("q", writeToken, "parts");
|
|
1680
|
+
_context21.t0 = this.utils;
|
|
1681
|
+
_context21.t1 = this.HttpClient;
|
|
1682
|
+
_context21.next = 8;
|
|
1683
|
+
return this.authClient.AuthorizationHeader({
|
|
1684
|
+
libraryId: libraryId,
|
|
1685
|
+
objectId: objectId,
|
|
1686
|
+
update: true,
|
|
1687
|
+
encryption: encryption
|
|
1688
|
+
});
|
|
1689
|
+
case 8:
|
|
1690
|
+
_context21.t2 = _context21.sent;
|
|
1691
|
+
_context21.t3 = path;
|
|
1692
|
+
_context21.t4 = {
|
|
1693
|
+
headers: _context21.t2,
|
|
1694
|
+
method: "POST",
|
|
1695
|
+
path: _context21.t3,
|
|
1696
|
+
bodyType: "BINARY",
|
|
1697
|
+
body: "",
|
|
1698
|
+
failover: false
|
|
1699
|
+
};
|
|
1700
|
+
_context21.t5 = _context21.t1.Request.call(_context21.t1, _context21.t4);
|
|
1701
|
+
_context21.next = 14;
|
|
1702
|
+
return _context21.t0.ResponseToJson.call(_context21.t0, _context21.t5);
|
|
1703
|
+
case 14:
|
|
1704
|
+
openResponse = _context21.sent;
|
|
1705
|
+
return _context21.abrupt("return", openResponse.part.write_token);
|
|
1706
|
+
case 16:
|
|
1707
|
+
case "end":
|
|
1708
|
+
return _context21.stop();
|
|
2008
1709
|
}
|
|
2009
1710
|
}, _callee21, this);
|
|
2010
1711
|
}));
|
|
2011
|
-
|
|
2012
1712
|
return function (_x22) {
|
|
2013
1713
|
return _ref38.apply(this, arguments);
|
|
2014
1714
|
};
|
|
2015
1715
|
}();
|
|
1716
|
+
|
|
2016
1717
|
/**
|
|
2017
1718
|
* Upload data to an open part draft
|
|
2018
1719
|
*
|
|
@@ -2028,82 +1729,71 @@ exports.CreatePart = /*#__PURE__*/function () {
|
|
|
2028
1729
|
*
|
|
2029
1730
|
* @returns {Promise<string>} - The part write token for the part draft
|
|
2030
1731
|
*/
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
1732
|
exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
2034
1733
|
var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref39) {
|
|
2035
1734
|
var libraryId, objectId, writeToken, partWriteToken, chunk, encryption, conk, path;
|
|
2036
1735
|
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
2037
|
-
while (1) {
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
};
|
|
2091
|
-
_context22.t6 = _context22.t1.Request.call(_context22.t1, _context22.t5);
|
|
2092
|
-
_context22.next = 22;
|
|
2093
|
-
return _context22.t0.ResponseToJson.call(_context22.t0, _context22.t6);
|
|
2094
|
-
|
|
2095
|
-
case 22:
|
|
2096
|
-
case "end":
|
|
2097
|
-
return _context22.stop();
|
|
2098
|
-
}
|
|
1736
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1737
|
+
case 0:
|
|
1738
|
+
libraryId = _ref39.libraryId, objectId = _ref39.objectId, writeToken = _ref39.writeToken, partWriteToken = _ref39.partWriteToken, chunk = _ref39.chunk, encryption = _ref39.encryption;
|
|
1739
|
+
ValidateParameters({
|
|
1740
|
+
libraryId: libraryId,
|
|
1741
|
+
objectId: objectId
|
|
1742
|
+
});
|
|
1743
|
+
ValidateWriteToken(writeToken);
|
|
1744
|
+
if (!(encryption && encryption !== "none")) {
|
|
1745
|
+
_context22.next = 10;
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
_context22.next = 6;
|
|
1749
|
+
return this.EncryptionConk({
|
|
1750
|
+
libraryId: libraryId,
|
|
1751
|
+
objectId: objectId,
|
|
1752
|
+
writeToken: writeToken
|
|
1753
|
+
});
|
|
1754
|
+
case 6:
|
|
1755
|
+
conk = _context22.sent;
|
|
1756
|
+
_context22.next = 9;
|
|
1757
|
+
return this.Crypto.Encrypt(conk, chunk);
|
|
1758
|
+
case 9:
|
|
1759
|
+
chunk = _context22.sent;
|
|
1760
|
+
case 10:
|
|
1761
|
+
path = UrlJoin("q", writeToken, "parts");
|
|
1762
|
+
_context22.t0 = this.utils;
|
|
1763
|
+
_context22.t1 = this.HttpClient;
|
|
1764
|
+
_context22.next = 15;
|
|
1765
|
+
return this.authClient.AuthorizationHeader({
|
|
1766
|
+
libraryId: libraryId,
|
|
1767
|
+
objectId: objectId,
|
|
1768
|
+
update: true,
|
|
1769
|
+
encryption: encryption
|
|
1770
|
+
});
|
|
1771
|
+
case 15:
|
|
1772
|
+
_context22.t2 = _context22.sent;
|
|
1773
|
+
_context22.t3 = UrlJoin(path, partWriteToken);
|
|
1774
|
+
_context22.t4 = chunk;
|
|
1775
|
+
_context22.t5 = {
|
|
1776
|
+
headers: _context22.t2,
|
|
1777
|
+
method: "POST",
|
|
1778
|
+
path: _context22.t3,
|
|
1779
|
+
body: _context22.t4,
|
|
1780
|
+
bodyType: "BINARY",
|
|
1781
|
+
failover: false
|
|
1782
|
+
};
|
|
1783
|
+
_context22.t6 = _context22.t1.Request.call(_context22.t1, _context22.t5);
|
|
1784
|
+
_context22.next = 22;
|
|
1785
|
+
return _context22.t0.ResponseToJson.call(_context22.t0, _context22.t6);
|
|
1786
|
+
case 22:
|
|
1787
|
+
case "end":
|
|
1788
|
+
return _context22.stop();
|
|
2099
1789
|
}
|
|
2100
1790
|
}, _callee22, this);
|
|
2101
1791
|
}));
|
|
2102
|
-
|
|
2103
1792
|
return function (_x23) {
|
|
2104
1793
|
return _ref40.apply(this, arguments);
|
|
2105
1794
|
};
|
|
2106
1795
|
}();
|
|
1796
|
+
|
|
2107
1797
|
/**
|
|
2108
1798
|
* Finalize an open part draft
|
|
2109
1799
|
*
|
|
@@ -2118,66 +1808,58 @@ exports.UploadPartChunk = /*#__PURE__*/function () {
|
|
|
2118
1808
|
*
|
|
2119
1809
|
* @returns {Promise<object>} - The finalize response for the new part
|
|
2120
1810
|
*/
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
1811
|
exports.FinalizePart = /*#__PURE__*/function () {
|
|
2124
1812
|
var _ref42 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref41) {
|
|
2125
1813
|
var libraryId, objectId, writeToken, partWriteToken, encryption, path;
|
|
2126
1814
|
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
2127
|
-
while (1) {
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
_context23.
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
return _context23.abrupt("return", _context23.sent);
|
|
2168
|
-
|
|
2169
|
-
case 17:
|
|
2170
|
-
case "end":
|
|
2171
|
-
return _context23.stop();
|
|
2172
|
-
}
|
|
1815
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1816
|
+
case 0:
|
|
1817
|
+
libraryId = _ref41.libraryId, objectId = _ref41.objectId, writeToken = _ref41.writeToken, partWriteToken = _ref41.partWriteToken, encryption = _ref41.encryption;
|
|
1818
|
+
ValidateParameters({
|
|
1819
|
+
libraryId: libraryId,
|
|
1820
|
+
objectId: objectId
|
|
1821
|
+
});
|
|
1822
|
+
ValidateWriteToken(writeToken);
|
|
1823
|
+
path = UrlJoin("q", writeToken, "parts");
|
|
1824
|
+
_context23.t0 = this.utils;
|
|
1825
|
+
_context23.t1 = this.HttpClient;
|
|
1826
|
+
_context23.next = 8;
|
|
1827
|
+
return this.authClient.AuthorizationHeader({
|
|
1828
|
+
libraryId: libraryId,
|
|
1829
|
+
objectId: objectId,
|
|
1830
|
+
update: true,
|
|
1831
|
+
encryption: encryption
|
|
1832
|
+
});
|
|
1833
|
+
case 8:
|
|
1834
|
+
_context23.t2 = _context23.sent;
|
|
1835
|
+
_context23.t3 = UrlJoin(path, partWriteToken);
|
|
1836
|
+
_context23.t4 = {
|
|
1837
|
+
headers: _context23.t2,
|
|
1838
|
+
method: "POST",
|
|
1839
|
+
path: _context23.t3,
|
|
1840
|
+
bodyType: "BINARY",
|
|
1841
|
+
body: "",
|
|
1842
|
+
failover: false
|
|
1843
|
+
};
|
|
1844
|
+
_context23.next = 13;
|
|
1845
|
+
return _context23.t1.Request.call(_context23.t1, _context23.t4);
|
|
1846
|
+
case 13:
|
|
1847
|
+
_context23.t5 = _context23.sent;
|
|
1848
|
+
_context23.next = 16;
|
|
1849
|
+
return _context23.t0.ResponseToJson.call(_context23.t0, _context23.t5);
|
|
1850
|
+
case 16:
|
|
1851
|
+
return _context23.abrupt("return", _context23.sent);
|
|
1852
|
+
case 17:
|
|
1853
|
+
case "end":
|
|
1854
|
+
return _context23.stop();
|
|
2173
1855
|
}
|
|
2174
1856
|
}, _callee23, this);
|
|
2175
1857
|
}));
|
|
2176
|
-
|
|
2177
1858
|
return function (_x24) {
|
|
2178
1859
|
return _ref42.apply(this, arguments);
|
|
2179
1860
|
};
|
|
2180
1861
|
}();
|
|
1862
|
+
|
|
2181
1863
|
/**
|
|
2182
1864
|
* Upload part to an object draft
|
|
2183
1865
|
*
|
|
@@ -2199,98 +1881,83 @@ exports.FinalizePart = /*#__PURE__*/function () {
|
|
|
2199
1881
|
*
|
|
2200
1882
|
* @returns {Promise<Object>} - Response containing information about the uploaded part
|
|
2201
1883
|
*/
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
1884
|
exports.UploadPart = /*#__PURE__*/function () {
|
|
2205
1885
|
var _ref44 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref43) {
|
|
2206
1886
|
var libraryId, objectId, writeToken, data, _ref43$encryption, encryption, _ref43$chunkSize, chunkSize, callback, partWriteToken, size, i, chunk;
|
|
2207
|
-
|
|
2208
1887
|
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
2209
|
-
while (1) {
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
callback({
|
|
2232
|
-
bytesFinished: 0,
|
|
2233
|
-
bytesTotal: size
|
|
2234
|
-
});
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
i = 0;
|
|
2238
|
-
|
|
2239
|
-
case 9:
|
|
2240
|
-
if (!(i < size)) {
|
|
2241
|
-
_context24.next = 17;
|
|
2242
|
-
break;
|
|
2243
|
-
}
|
|
2244
|
-
|
|
2245
|
-
chunk = data.slice(i, i + chunkSize);
|
|
2246
|
-
_context24.next = 13;
|
|
2247
|
-
return this.UploadPartChunk({
|
|
2248
|
-
libraryId: libraryId,
|
|
2249
|
-
objectId: objectId,
|
|
2250
|
-
writeToken: writeToken,
|
|
2251
|
-
partWriteToken: partWriteToken,
|
|
2252
|
-
chunk: chunk,
|
|
2253
|
-
encryption: encryption
|
|
1888
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1889
|
+
case 0:
|
|
1890
|
+
libraryId = _ref43.libraryId, objectId = _ref43.objectId, writeToken = _ref43.writeToken, data = _ref43.data, _ref43$encryption = _ref43.encryption, encryption = _ref43$encryption === void 0 ? "none" : _ref43$encryption, _ref43$chunkSize = _ref43.chunkSize, chunkSize = _ref43$chunkSize === void 0 ? 10000000 : _ref43$chunkSize, callback = _ref43.callback;
|
|
1891
|
+
ValidateParameters({
|
|
1892
|
+
libraryId: libraryId,
|
|
1893
|
+
objectId: objectId
|
|
1894
|
+
});
|
|
1895
|
+
ValidateWriteToken(writeToken);
|
|
1896
|
+
_context24.next = 5;
|
|
1897
|
+
return this.CreatePart({
|
|
1898
|
+
libraryId: libraryId,
|
|
1899
|
+
objectId: objectId,
|
|
1900
|
+
writeToken: writeToken,
|
|
1901
|
+
encryption: encryption
|
|
1902
|
+
});
|
|
1903
|
+
case 5:
|
|
1904
|
+
partWriteToken = _context24.sent;
|
|
1905
|
+
size = data.length || data.byteLength || data.size;
|
|
1906
|
+
if (callback) {
|
|
1907
|
+
callback({
|
|
1908
|
+
bytesFinished: 0,
|
|
1909
|
+
bytesTotal: size
|
|
2254
1910
|
});
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
bytesTotal: size
|
|
2261
|
-
});
|
|
2262
|
-
}
|
|
2263
|
-
|
|
2264
|
-
case 14:
|
|
2265
|
-
i += chunkSize;
|
|
2266
|
-
_context24.next = 9;
|
|
1911
|
+
}
|
|
1912
|
+
i = 0;
|
|
1913
|
+
case 9:
|
|
1914
|
+
if (!(i < size)) {
|
|
1915
|
+
_context24.next = 17;
|
|
2267
1916
|
break;
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
1917
|
+
}
|
|
1918
|
+
chunk = data.slice(i, i + chunkSize);
|
|
1919
|
+
_context24.next = 13;
|
|
1920
|
+
return this.UploadPartChunk({
|
|
1921
|
+
libraryId: libraryId,
|
|
1922
|
+
objectId: objectId,
|
|
1923
|
+
writeToken: writeToken,
|
|
1924
|
+
partWriteToken: partWriteToken,
|
|
1925
|
+
chunk: chunk,
|
|
1926
|
+
encryption: encryption
|
|
1927
|
+
});
|
|
1928
|
+
case 13:
|
|
1929
|
+
if (callback) {
|
|
1930
|
+
callback({
|
|
1931
|
+
bytesFinished: Math.min(i + chunkSize, size),
|
|
1932
|
+
bytesTotal: size
|
|
2277
1933
|
});
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
1934
|
+
}
|
|
1935
|
+
case 14:
|
|
1936
|
+
i += chunkSize;
|
|
1937
|
+
_context24.next = 9;
|
|
1938
|
+
break;
|
|
1939
|
+
case 17:
|
|
1940
|
+
_context24.next = 19;
|
|
1941
|
+
return this.FinalizePart({
|
|
1942
|
+
libraryId: libraryId,
|
|
1943
|
+
objectId: objectId,
|
|
1944
|
+
writeToken: writeToken,
|
|
1945
|
+
partWriteToken: partWriteToken,
|
|
1946
|
+
encryption: encryption
|
|
1947
|
+
});
|
|
1948
|
+
case 19:
|
|
1949
|
+
return _context24.abrupt("return", _context24.sent);
|
|
1950
|
+
case 20:
|
|
1951
|
+
case "end":
|
|
1952
|
+
return _context24.stop();
|
|
2286
1953
|
}
|
|
2287
1954
|
}, _callee24, this);
|
|
2288
1955
|
}));
|
|
2289
|
-
|
|
2290
1956
|
return function (_x25) {
|
|
2291
1957
|
return _ref44.apply(this, arguments);
|
|
2292
1958
|
};
|
|
2293
1959
|
}();
|
|
1960
|
+
|
|
2294
1961
|
/**
|
|
2295
1962
|
* Delete the specified part from a content draft
|
|
2296
1963
|
*
|
|
@@ -2302,51 +1969,44 @@ exports.UploadPart = /*#__PURE__*/function () {
|
|
|
2302
1969
|
* @param {string} writeToken - Write token of the content object draft
|
|
2303
1970
|
* @param {string} partHash - Hash of the part to delete
|
|
2304
1971
|
*/
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
1972
|
exports.DeletePart = /*#__PURE__*/function () {
|
|
2308
1973
|
var _ref46 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref45) {
|
|
2309
1974
|
var libraryId, objectId, writeToken, partHash, path;
|
|
2310
1975
|
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
2311
|
-
while (1) {
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
_context25.
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
case 13:
|
|
2343
|
-
case "end":
|
|
2344
|
-
return _context25.stop();
|
|
2345
|
-
}
|
|
1976
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1977
|
+
case 0:
|
|
1978
|
+
libraryId = _ref45.libraryId, objectId = _ref45.objectId, writeToken = _ref45.writeToken, partHash = _ref45.partHash;
|
|
1979
|
+
ValidateParameters({
|
|
1980
|
+
libraryId: libraryId,
|
|
1981
|
+
objectId: objectId
|
|
1982
|
+
});
|
|
1983
|
+
ValidateWriteToken(writeToken);
|
|
1984
|
+
ValidatePartHash(partHash);
|
|
1985
|
+
path = UrlJoin("q", writeToken, "parts", partHash);
|
|
1986
|
+
_context25.t0 = this.HttpClient;
|
|
1987
|
+
_context25.next = 8;
|
|
1988
|
+
return this.authClient.AuthorizationHeader({
|
|
1989
|
+
libraryId: libraryId,
|
|
1990
|
+
objectId: objectId,
|
|
1991
|
+
update: true
|
|
1992
|
+
});
|
|
1993
|
+
case 8:
|
|
1994
|
+
_context25.t1 = _context25.sent;
|
|
1995
|
+
_context25.t2 = path;
|
|
1996
|
+
_context25.t3 = {
|
|
1997
|
+
headers: _context25.t1,
|
|
1998
|
+
method: "DELETE",
|
|
1999
|
+
path: _context25.t2,
|
|
2000
|
+
failover: false
|
|
2001
|
+
};
|
|
2002
|
+
_context25.next = 13;
|
|
2003
|
+
return _context25.t0.Request.call(_context25.t0, _context25.t3);
|
|
2004
|
+
case 13:
|
|
2005
|
+
case "end":
|
|
2006
|
+
return _context25.stop();
|
|
2346
2007
|
}
|
|
2347
2008
|
}, _callee25, this);
|
|
2348
2009
|
}));
|
|
2349
|
-
|
|
2350
2010
|
return function (_x26) {
|
|
2351
2011
|
return _ref46.apply(this, arguments);
|
|
2352
2012
|
};
|