files.com 1.0.256 → 1.0.258
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/README.md +3 -0
- package/_VERSION +1 -1
- package/lib/isomorphic/File.node.js +39 -9
- package/lib/models/File.js +303 -277
- package/package.json +1 -1
- package/shared/normalization_for_comparison_test_data.json +38 -0
- package/src/isomorphic/File.node.js +14 -0
- package/src/models/File.js +15 -0
- package/test/src/index.js +34 -3
package/lib/models/File.js
CHANGED
@@ -66,75 +66,101 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
66
66
|
return _ref.apply(this, arguments);
|
67
67
|
};
|
68
68
|
}());
|
69
|
+
(0, _defineProperty2.default)(this, "downloadToString", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
70
|
+
var downloadUri, _require2, saveUrlToString;
|
71
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
72
|
+
while (1) switch (_context2.prev = _context2.next) {
|
73
|
+
case 0:
|
74
|
+
if (!(0, _utils.isBrowser)()) {
|
75
|
+
_context2.next = 2;
|
76
|
+
break;
|
77
|
+
}
|
78
|
+
throw new errors.NotImplementedError('String downloads are only available in a NodeJS environment');
|
79
|
+
case 2:
|
80
|
+
downloadUri = _this.getDownloadUri();
|
81
|
+
if (downloadUri) {
|
82
|
+
_context2.next = 5;
|
83
|
+
break;
|
84
|
+
}
|
85
|
+
throw new errors.EmptyPropertyError('Current object has no download URI');
|
86
|
+
case 5:
|
87
|
+
_require2 = require('../isomorphic/File.node.js'), saveUrlToString = _require2.saveUrlToString;
|
88
|
+
return _context2.abrupt("return", saveUrlToString(downloadUri));
|
89
|
+
case 7:
|
90
|
+
case "end":
|
91
|
+
return _context2.stop();
|
92
|
+
}
|
93
|
+
}, _callee2);
|
94
|
+
})));
|
69
95
|
(0, _defineProperty2.default)(this, "downloadToFile", /*#__PURE__*/function () {
|
70
|
-
var
|
71
|
-
var downloadUri,
|
72
|
-
return _regenerator.default.wrap(function
|
73
|
-
while (1) switch (
|
96
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(destinationPath) {
|
97
|
+
var downloadUri, _require3, saveUrlToFile;
|
98
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
99
|
+
while (1) switch (_context3.prev = _context3.next) {
|
74
100
|
case 0:
|
75
101
|
if (!(0, _utils.isBrowser)()) {
|
76
|
-
|
102
|
+
_context3.next = 2;
|
77
103
|
break;
|
78
104
|
}
|
79
105
|
throw new errors.NotImplementedError('Disk file downloads are only available in a NodeJS environment');
|
80
106
|
case 2:
|
81
107
|
downloadUri = _this.getDownloadUri();
|
82
108
|
if (downloadUri) {
|
83
|
-
|
109
|
+
_context3.next = 5;
|
84
110
|
break;
|
85
111
|
}
|
86
112
|
throw new errors.EmptyPropertyError('Current object has no download URI');
|
87
113
|
case 5:
|
88
|
-
|
89
|
-
return
|
114
|
+
_require3 = require('../isomorphic/File.node.js'), saveUrlToFile = _require3.saveUrlToFile;
|
115
|
+
return _context3.abrupt("return", saveUrlToFile(downloadUri, destinationPath));
|
90
116
|
case 7:
|
91
117
|
case "end":
|
92
|
-
return
|
118
|
+
return _context3.stop();
|
93
119
|
}
|
94
|
-
},
|
120
|
+
}, _callee3);
|
95
121
|
}));
|
96
122
|
return function (_x2) {
|
97
|
-
return
|
123
|
+
return _ref3.apply(this, arguments);
|
98
124
|
};
|
99
125
|
}());
|
100
126
|
(0, _defineProperty2.default)(this, "copyTo", /*#__PURE__*/function () {
|
101
|
-
var
|
127
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(destinationFilePath, options) {
|
102
128
|
var params;
|
103
|
-
return _regenerator.default.wrap(function
|
104
|
-
while (1) switch (
|
129
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
130
|
+
while (1) switch (_context4.prev = _context4.next) {
|
105
131
|
case 0:
|
106
132
|
params = {
|
107
133
|
destination: destinationFilePath
|
108
134
|
};
|
109
|
-
return
|
135
|
+
return _context4.abrupt("return", _Api.default.sendRequest("/file_actions/copy/".concat(encodeURIComponent(_this.path)), 'POST', params, options));
|
110
136
|
case 2:
|
111
137
|
case "end":
|
112
|
-
return
|
138
|
+
return _context4.stop();
|
113
139
|
}
|
114
|
-
},
|
140
|
+
}, _callee4);
|
115
141
|
}));
|
116
142
|
return function (_x3, _x4) {
|
117
|
-
return
|
143
|
+
return _ref4.apply(this, arguments);
|
118
144
|
};
|
119
145
|
}());
|
120
146
|
(0, _defineProperty2.default)(this, "moveTo", /*#__PURE__*/function () {
|
121
|
-
var
|
147
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(destinationFilePath, options) {
|
122
148
|
var params;
|
123
|
-
return _regenerator.default.wrap(function
|
124
|
-
while (1) switch (
|
149
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
150
|
+
while (1) switch (_context5.prev = _context5.next) {
|
125
151
|
case 0:
|
126
152
|
params = {
|
127
153
|
destination: destinationFilePath
|
128
154
|
};
|
129
|
-
return
|
155
|
+
return _context5.abrupt("return", _Api.default.sendRequest("/file_actions/move/".concat(encodeURIComponent(_this.path)), 'POST', params, options));
|
130
156
|
case 2:
|
131
157
|
case "end":
|
132
|
-
return
|
158
|
+
return _context5.stop();
|
133
159
|
}
|
134
|
-
},
|
160
|
+
}, _callee5);
|
135
161
|
}));
|
136
162
|
return function (_x5, _x6) {
|
137
|
-
return
|
163
|
+
return _ref5.apply(this, arguments);
|
138
164
|
};
|
139
165
|
}());
|
140
166
|
// string # File/Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
|
@@ -330,190 +356,190 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
330
356
|
// preview_size - string - Request a preview size. Can be `small` (default), `large`, `xlarge`, or `pdf`.
|
331
357
|
// with_previews - boolean - Include file preview information?
|
332
358
|
// with_priority_color - boolean - Include file priority color information?
|
333
|
-
(0, _defineProperty2.default)(this, "download", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
359
|
+
(0, _defineProperty2.default)(this, "download", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
334
360
|
var params,
|
335
361
|
response,
|
336
|
-
|
337
|
-
return _regenerator.default.wrap(function
|
338
|
-
while (1) switch (
|
362
|
+
_args6 = arguments;
|
363
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
364
|
+
while (1) switch (_context6.prev = _context6.next) {
|
339
365
|
case 0:
|
340
|
-
params =
|
366
|
+
params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
341
367
|
if (_this.attributes.path) {
|
342
|
-
|
368
|
+
_context6.next = 3;
|
343
369
|
break;
|
344
370
|
}
|
345
371
|
throw new errors.EmptyPropertyError('Current object has no path');
|
346
372
|
case 3:
|
347
373
|
if ((0, _utils.isObject)(params)) {
|
348
|
-
|
374
|
+
_context6.next = 5;
|
349
375
|
break;
|
350
376
|
}
|
351
377
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
352
378
|
case 5:
|
353
379
|
params.path = _this.attributes.path;
|
354
380
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
355
|
-
|
381
|
+
_context6.next = 8;
|
356
382
|
break;
|
357
383
|
}
|
358
384
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
359
385
|
case 8:
|
360
386
|
if (!(params['action'] && !(0, _utils.isString)(params['action']))) {
|
361
|
-
|
387
|
+
_context6.next = 10;
|
362
388
|
break;
|
363
389
|
}
|
364
390
|
throw new errors.InvalidParameterError("Bad parameter: action must be of type String, received ".concat((0, _utils.getType)(action)));
|
365
391
|
case 10:
|
366
392
|
if (!(params['preview_size'] && !(0, _utils.isString)(params['preview_size']))) {
|
367
|
-
|
393
|
+
_context6.next = 12;
|
368
394
|
break;
|
369
395
|
}
|
370
396
|
throw new errors.InvalidParameterError("Bad parameter: preview_size must be of type String, received ".concat((0, _utils.getType)(preview_size)));
|
371
397
|
case 12:
|
372
398
|
if (params['path']) {
|
373
|
-
|
399
|
+
_context6.next = 18;
|
374
400
|
break;
|
375
401
|
}
|
376
402
|
if (!_this.attributes.path) {
|
377
|
-
|
403
|
+
_context6.next = 17;
|
378
404
|
break;
|
379
405
|
}
|
380
406
|
params['path'] = _this.path;
|
381
|
-
|
407
|
+
_context6.next = 18;
|
382
408
|
break;
|
383
409
|
case 17:
|
384
410
|
throw new errors.MissingParameterError('Parameter missing: path');
|
385
411
|
case 18:
|
386
|
-
|
412
|
+
_context6.next = 20;
|
387
413
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(params['path'])), 'GET', params, _this.options);
|
388
414
|
case 20:
|
389
|
-
response =
|
390
|
-
return
|
415
|
+
response = _context6.sent;
|
416
|
+
return _context6.abrupt("return", new File(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
391
417
|
case 22:
|
392
418
|
case "end":
|
393
|
-
return
|
419
|
+
return _context6.stop();
|
394
420
|
}
|
395
|
-
},
|
421
|
+
}, _callee6);
|
396
422
|
})));
|
397
423
|
// Parameters:
|
398
424
|
// provided_mtime - string - Modified time of file.
|
399
425
|
// priority_color - string - Priority/Bookmark color of file.
|
400
|
-
(0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
426
|
+
(0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
401
427
|
var params,
|
402
428
|
response,
|
403
|
-
|
404
|
-
return _regenerator.default.wrap(function
|
405
|
-
while (1) switch (
|
429
|
+
_args7 = arguments;
|
430
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
431
|
+
while (1) switch (_context7.prev = _context7.next) {
|
406
432
|
case 0:
|
407
|
-
params =
|
433
|
+
params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
408
434
|
if (_this.attributes.path) {
|
409
|
-
|
435
|
+
_context7.next = 3;
|
410
436
|
break;
|
411
437
|
}
|
412
438
|
throw new errors.EmptyPropertyError('Current object has no path');
|
413
439
|
case 3:
|
414
440
|
if ((0, _utils.isObject)(params)) {
|
415
|
-
|
441
|
+
_context7.next = 5;
|
416
442
|
break;
|
417
443
|
}
|
418
444
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
419
445
|
case 5:
|
420
446
|
params.path = _this.attributes.path;
|
421
447
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
422
|
-
|
448
|
+
_context7.next = 8;
|
423
449
|
break;
|
424
450
|
}
|
425
451
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
426
452
|
case 8:
|
427
453
|
if (!(params['provided_mtime'] && !(0, _utils.isString)(params['provided_mtime']))) {
|
428
|
-
|
454
|
+
_context7.next = 10;
|
429
455
|
break;
|
430
456
|
}
|
431
457
|
throw new errors.InvalidParameterError("Bad parameter: provided_mtime must be of type String, received ".concat((0, _utils.getType)(provided_mtime)));
|
432
458
|
case 10:
|
433
459
|
if (!(params['priority_color'] && !(0, _utils.isString)(params['priority_color']))) {
|
434
|
-
|
460
|
+
_context7.next = 12;
|
435
461
|
break;
|
436
462
|
}
|
437
463
|
throw new errors.InvalidParameterError("Bad parameter: priority_color must be of type String, received ".concat((0, _utils.getType)(priority_color)));
|
438
464
|
case 12:
|
439
465
|
if (params['path']) {
|
440
|
-
|
466
|
+
_context7.next = 18;
|
441
467
|
break;
|
442
468
|
}
|
443
469
|
if (!_this.attributes.path) {
|
444
|
-
|
470
|
+
_context7.next = 17;
|
445
471
|
break;
|
446
472
|
}
|
447
473
|
params['path'] = _this.path;
|
448
|
-
|
474
|
+
_context7.next = 18;
|
449
475
|
break;
|
450
476
|
case 17:
|
451
477
|
throw new errors.MissingParameterError('Parameter missing: path');
|
452
478
|
case 18:
|
453
|
-
|
479
|
+
_context7.next = 20;
|
454
480
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(params['path'])), 'PATCH', params, _this.options);
|
455
481
|
case 20:
|
456
|
-
response =
|
457
|
-
return
|
482
|
+
response = _context7.sent;
|
483
|
+
return _context7.abrupt("return", new File(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
458
484
|
case 22:
|
459
485
|
case "end":
|
460
|
-
return
|
486
|
+
return _context7.stop();
|
461
487
|
}
|
462
|
-
},
|
488
|
+
}, _callee7);
|
463
489
|
})));
|
464
490
|
// Parameters:
|
465
491
|
// recursive - boolean - If true, will recursively delete folers. Otherwise, will error on non-empty folders.
|
466
|
-
(0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
492
|
+
(0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
467
493
|
var params,
|
468
494
|
response,
|
469
|
-
|
470
|
-
return _regenerator.default.wrap(function
|
471
|
-
while (1) switch (
|
495
|
+
_args8 = arguments;
|
496
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
497
|
+
while (1) switch (_context8.prev = _context8.next) {
|
472
498
|
case 0:
|
473
|
-
params =
|
499
|
+
params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
|
474
500
|
if (_this.attributes.path) {
|
475
|
-
|
501
|
+
_context8.next = 3;
|
476
502
|
break;
|
477
503
|
}
|
478
504
|
throw new errors.EmptyPropertyError('Current object has no path');
|
479
505
|
case 3:
|
480
506
|
if ((0, _utils.isObject)(params)) {
|
481
|
-
|
507
|
+
_context8.next = 5;
|
482
508
|
break;
|
483
509
|
}
|
484
510
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
485
511
|
case 5:
|
486
512
|
params.path = _this.attributes.path;
|
487
513
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
488
|
-
|
514
|
+
_context8.next = 8;
|
489
515
|
break;
|
490
516
|
}
|
491
517
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
492
518
|
case 8:
|
493
519
|
if (params['path']) {
|
494
|
-
|
520
|
+
_context8.next = 14;
|
495
521
|
break;
|
496
522
|
}
|
497
523
|
if (!_this.attributes.path) {
|
498
|
-
|
524
|
+
_context8.next = 13;
|
499
525
|
break;
|
500
526
|
}
|
501
527
|
params['path'] = _this.path;
|
502
|
-
|
528
|
+
_context8.next = 14;
|
503
529
|
break;
|
504
530
|
case 13:
|
505
531
|
throw new errors.MissingParameterError('Parameter missing: path');
|
506
532
|
case 14:
|
507
|
-
|
533
|
+
_context8.next = 16;
|
508
534
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(params['path'])), 'DELETE', params, _this.options);
|
509
535
|
case 16:
|
510
|
-
response =
|
511
|
-
return
|
536
|
+
response = _context8.sent;
|
537
|
+
return _context8.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
512
538
|
case 18:
|
513
539
|
case "end":
|
514
|
-
return
|
540
|
+
return _context8.stop();
|
515
541
|
}
|
516
|
-
},
|
542
|
+
}, _callee8);
|
517
543
|
})));
|
518
544
|
(0, _defineProperty2.default)(this, "destroy", function () {
|
519
545
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
@@ -524,153 +550,153 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
524
550
|
// Parameters:
|
525
551
|
// destination (required) - string - Copy destination path.
|
526
552
|
// structure - boolean - Copy structure only?
|
527
|
-
(0, _defineProperty2.default)(this, "copy", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
553
|
+
(0, _defineProperty2.default)(this, "copy", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
528
554
|
var params,
|
529
555
|
response,
|
530
|
-
|
531
|
-
return _regenerator.default.wrap(function
|
532
|
-
while (1) switch (
|
556
|
+
_args9 = arguments;
|
557
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
558
|
+
while (1) switch (_context9.prev = _context9.next) {
|
533
559
|
case 0:
|
534
|
-
params =
|
560
|
+
params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
535
561
|
if (_this.attributes.path) {
|
536
|
-
|
562
|
+
_context9.next = 3;
|
537
563
|
break;
|
538
564
|
}
|
539
565
|
throw new errors.EmptyPropertyError('Current object has no path');
|
540
566
|
case 3:
|
541
567
|
if ((0, _utils.isObject)(params)) {
|
542
|
-
|
568
|
+
_context9.next = 5;
|
543
569
|
break;
|
544
570
|
}
|
545
571
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
546
572
|
case 5:
|
547
573
|
params.path = _this.attributes.path;
|
548
574
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
549
|
-
|
575
|
+
_context9.next = 8;
|
550
576
|
break;
|
551
577
|
}
|
552
578
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
553
579
|
case 8:
|
554
580
|
if (!(params['destination'] && !(0, _utils.isString)(params['destination']))) {
|
555
|
-
|
581
|
+
_context9.next = 10;
|
556
582
|
break;
|
557
583
|
}
|
558
584
|
throw new errors.InvalidParameterError("Bad parameter: destination must be of type String, received ".concat((0, _utils.getType)(destination)));
|
559
585
|
case 10:
|
560
586
|
if (params['path']) {
|
561
|
-
|
587
|
+
_context9.next = 16;
|
562
588
|
break;
|
563
589
|
}
|
564
590
|
if (!_this.attributes.path) {
|
565
|
-
|
591
|
+
_context9.next = 15;
|
566
592
|
break;
|
567
593
|
}
|
568
594
|
params['path'] = _this.path;
|
569
|
-
|
595
|
+
_context9.next = 16;
|
570
596
|
break;
|
571
597
|
case 15:
|
572
598
|
throw new errors.MissingParameterError('Parameter missing: path');
|
573
599
|
case 16:
|
574
600
|
if (params['destination']) {
|
575
|
-
|
601
|
+
_context9.next = 22;
|
576
602
|
break;
|
577
603
|
}
|
578
604
|
if (!_this.attributes.destination) {
|
579
|
-
|
605
|
+
_context9.next = 21;
|
580
606
|
break;
|
581
607
|
}
|
582
608
|
params['destination'] = _this.destination;
|
583
|
-
|
609
|
+
_context9.next = 22;
|
584
610
|
break;
|
585
611
|
case 21:
|
586
612
|
throw new errors.MissingParameterError('Parameter missing: destination');
|
587
613
|
case 22:
|
588
|
-
|
614
|
+
_context9.next = 24;
|
589
615
|
return _Api.default.sendRequest("/file_actions/copy/".concat(encodeURIComponent(params['path'])), 'POST', params, _this.options);
|
590
616
|
case 24:
|
591
|
-
response =
|
592
|
-
return
|
617
|
+
response = _context9.sent;
|
618
|
+
return _context9.abrupt("return", new _FileAction.default(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
593
619
|
case 26:
|
594
620
|
case "end":
|
595
|
-
return
|
621
|
+
return _context9.stop();
|
596
622
|
}
|
597
|
-
},
|
623
|
+
}, _callee9);
|
598
624
|
})));
|
599
625
|
// Move file/folder
|
600
626
|
//
|
601
627
|
// Parameters:
|
602
628
|
// destination (required) - string - Move destination path.
|
603
|
-
(0, _defineProperty2.default)(this, "move", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
629
|
+
(0, _defineProperty2.default)(this, "move", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
604
630
|
var params,
|
605
631
|
response,
|
606
|
-
|
607
|
-
return _regenerator.default.wrap(function
|
608
|
-
while (1) switch (
|
632
|
+
_args10 = arguments;
|
633
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
634
|
+
while (1) switch (_context10.prev = _context10.next) {
|
609
635
|
case 0:
|
610
|
-
params =
|
636
|
+
params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
|
611
637
|
if (_this.attributes.path) {
|
612
|
-
|
638
|
+
_context10.next = 3;
|
613
639
|
break;
|
614
640
|
}
|
615
641
|
throw new errors.EmptyPropertyError('Current object has no path');
|
616
642
|
case 3:
|
617
643
|
if ((0, _utils.isObject)(params)) {
|
618
|
-
|
644
|
+
_context10.next = 5;
|
619
645
|
break;
|
620
646
|
}
|
621
647
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
622
648
|
case 5:
|
623
649
|
params.path = _this.attributes.path;
|
624
650
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
625
|
-
|
651
|
+
_context10.next = 8;
|
626
652
|
break;
|
627
653
|
}
|
628
654
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
629
655
|
case 8:
|
630
656
|
if (!(params['destination'] && !(0, _utils.isString)(params['destination']))) {
|
631
|
-
|
657
|
+
_context10.next = 10;
|
632
658
|
break;
|
633
659
|
}
|
634
660
|
throw new errors.InvalidParameterError("Bad parameter: destination must be of type String, received ".concat((0, _utils.getType)(destination)));
|
635
661
|
case 10:
|
636
662
|
if (params['path']) {
|
637
|
-
|
663
|
+
_context10.next = 16;
|
638
664
|
break;
|
639
665
|
}
|
640
666
|
if (!_this.attributes.path) {
|
641
|
-
|
667
|
+
_context10.next = 15;
|
642
668
|
break;
|
643
669
|
}
|
644
670
|
params['path'] = _this.path;
|
645
|
-
|
671
|
+
_context10.next = 16;
|
646
672
|
break;
|
647
673
|
case 15:
|
648
674
|
throw new errors.MissingParameterError('Parameter missing: path');
|
649
675
|
case 16:
|
650
676
|
if (params['destination']) {
|
651
|
-
|
677
|
+
_context10.next = 22;
|
652
678
|
break;
|
653
679
|
}
|
654
680
|
if (!_this.attributes.destination) {
|
655
|
-
|
681
|
+
_context10.next = 21;
|
656
682
|
break;
|
657
683
|
}
|
658
684
|
params['destination'] = _this.destination;
|
659
|
-
|
685
|
+
_context10.next = 22;
|
660
686
|
break;
|
661
687
|
case 21:
|
662
688
|
throw new errors.MissingParameterError('Parameter missing: destination');
|
663
689
|
case 22:
|
664
|
-
|
690
|
+
_context10.next = 24;
|
665
691
|
return _Api.default.sendRequest("/file_actions/move/".concat(encodeURIComponent(params['path'])), 'POST', params, _this.options);
|
666
692
|
case 24:
|
667
|
-
response =
|
668
|
-
return
|
693
|
+
response = _context10.sent;
|
694
|
+
return _context10.abrupt("return", new _FileAction.default(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
669
695
|
case 26:
|
670
696
|
case "end":
|
671
|
-
return
|
697
|
+
return _context10.stop();
|
672
698
|
}
|
673
|
-
},
|
699
|
+
}, _callee10);
|
674
700
|
})));
|
675
701
|
// Begin file upload
|
676
702
|
//
|
@@ -682,100 +708,100 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
682
708
|
// restart - int64 - File byte offset to restart from.
|
683
709
|
// size - int64 - Total bytes of file being uploaded (include bytes being retained if appending/restarting).
|
684
710
|
// with_rename - boolean - Allow file rename instead of overwrite?
|
685
|
-
(0, _defineProperty2.default)(this, "beginUpload", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
711
|
+
(0, _defineProperty2.default)(this, "beginUpload", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
686
712
|
var _response$data;
|
687
713
|
var params,
|
688
714
|
response,
|
689
|
-
|
690
|
-
return _regenerator.default.wrap(function
|
691
|
-
while (1) switch (
|
715
|
+
_args11 = arguments;
|
716
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
717
|
+
while (1) switch (_context11.prev = _context11.next) {
|
692
718
|
case 0:
|
693
|
-
params =
|
719
|
+
params = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
|
694
720
|
if (_this.attributes.path) {
|
695
|
-
|
721
|
+
_context11.next = 3;
|
696
722
|
break;
|
697
723
|
}
|
698
724
|
throw new errors.EmptyPropertyError('Current object has no path');
|
699
725
|
case 3:
|
700
726
|
if ((0, _utils.isObject)(params)) {
|
701
|
-
|
727
|
+
_context11.next = 5;
|
702
728
|
break;
|
703
729
|
}
|
704
730
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
705
731
|
case 5:
|
706
732
|
params.path = _this.attributes.path;
|
707
733
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
708
|
-
|
734
|
+
_context11.next = 8;
|
709
735
|
break;
|
710
736
|
}
|
711
737
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
712
738
|
case 8:
|
713
739
|
if (!(params['part'] && !(0, _utils.isInt)(params['part']))) {
|
714
|
-
|
740
|
+
_context11.next = 10;
|
715
741
|
break;
|
716
742
|
}
|
717
743
|
throw new errors.InvalidParameterError("Bad parameter: part must be of type Int, received ".concat((0, _utils.getType)(part)));
|
718
744
|
case 10:
|
719
745
|
if (!(params['parts'] && !(0, _utils.isInt)(params['parts']))) {
|
720
|
-
|
746
|
+
_context11.next = 12;
|
721
747
|
break;
|
722
748
|
}
|
723
749
|
throw new errors.InvalidParameterError("Bad parameter: parts must be of type Int, received ".concat((0, _utils.getType)(parts)));
|
724
750
|
case 12:
|
725
751
|
if (!(params['ref'] && !(0, _utils.isString)(params['ref']))) {
|
726
|
-
|
752
|
+
_context11.next = 14;
|
727
753
|
break;
|
728
754
|
}
|
729
755
|
throw new errors.InvalidParameterError("Bad parameter: ref must be of type String, received ".concat((0, _utils.getType)(ref)));
|
730
756
|
case 14:
|
731
757
|
if (!(params['restart'] && !(0, _utils.isInt)(params['restart']))) {
|
732
|
-
|
758
|
+
_context11.next = 16;
|
733
759
|
break;
|
734
760
|
}
|
735
761
|
throw new errors.InvalidParameterError("Bad parameter: restart must be of type Int, received ".concat((0, _utils.getType)(restart)));
|
736
762
|
case 16:
|
737
763
|
if (!(params['size'] && !(0, _utils.isInt)(params['size']))) {
|
738
|
-
|
764
|
+
_context11.next = 18;
|
739
765
|
break;
|
740
766
|
}
|
741
767
|
throw new errors.InvalidParameterError("Bad parameter: size must be of type Int, received ".concat((0, _utils.getType)(size)));
|
742
768
|
case 18:
|
743
769
|
if (params['path']) {
|
744
|
-
|
770
|
+
_context11.next = 24;
|
745
771
|
break;
|
746
772
|
}
|
747
773
|
if (!_this.attributes.path) {
|
748
|
-
|
774
|
+
_context11.next = 23;
|
749
775
|
break;
|
750
776
|
}
|
751
777
|
params['path'] = _this.path;
|
752
|
-
|
778
|
+
_context11.next = 24;
|
753
779
|
break;
|
754
780
|
case 23:
|
755
781
|
throw new errors.MissingParameterError('Parameter missing: path');
|
756
782
|
case 24:
|
757
|
-
|
783
|
+
_context11.next = 26;
|
758
784
|
return _Api.default.sendRequest("/file_actions/begin_upload/".concat(encodeURIComponent(params['path'])), 'POST', params, _this.options);
|
759
785
|
case 26:
|
760
|
-
response =
|
761
|
-
return
|
786
|
+
response = _context11.sent;
|
787
|
+
return _context11.abrupt("return", (response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
|
762
788
|
return new _FileUploadPart.default(obj, _this.options);
|
763
789
|
})) || []);
|
764
790
|
case 28:
|
765
791
|
case "end":
|
766
|
-
return
|
792
|
+
return _context11.stop();
|
767
793
|
}
|
768
|
-
},
|
794
|
+
}, _callee11);
|
769
795
|
})));
|
770
796
|
(0, _defineProperty2.default)(this, "save", function () {
|
771
797
|
var newObject = File.create(_this.attributes.path, _this.attributes, _this.options);
|
772
798
|
_this.attributes = _objectSpread({}, newObject.attributes);
|
773
799
|
return true;
|
774
800
|
});
|
775
|
-
Object.entries(attributes).forEach(function (
|
776
|
-
var
|
777
|
-
key =
|
778
|
-
value =
|
801
|
+
Object.entries(attributes).forEach(function (_ref12) {
|
802
|
+
var _ref13 = (0, _slicedToArray2.default)(_ref12, 2),
|
803
|
+
key = _ref13[0],
|
804
|
+
value = _ref13[1];
|
779
805
|
var normalizedKey = key.replace('?', '');
|
780
806
|
_this.attributes[normalizedKey] = value;
|
781
807
|
Object.defineProperty(_this, normalizedKey, {
|
@@ -786,117 +812,117 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
786
812
|
this.options = _objectSpread({}, _options);
|
787
813
|
});
|
788
814
|
(0, _defineProperty2.default)(File, "_openUpload", /*#__PURE__*/function () {
|
789
|
-
var
|
815
|
+
var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(path, paramsRaw, options) {
|
790
816
|
var params, response, partData;
|
791
|
-
return _regenerator.default.wrap(function
|
792
|
-
while (1) switch (
|
817
|
+
return _regenerator.default.wrap(function _callee12$(_context12) {
|
818
|
+
while (1) switch (_context12.prev = _context12.next) {
|
793
819
|
case 0:
|
794
820
|
params = _objectSpread(_objectSpread({}, paramsRaw), {}, {
|
795
821
|
action: 'put'
|
796
822
|
});
|
797
|
-
|
823
|
+
_context12.next = 3;
|
798
824
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(path)), 'POST', params, options);
|
799
825
|
case 3:
|
800
|
-
response =
|
826
|
+
response = _context12.sent;
|
801
827
|
if (response) {
|
802
|
-
|
828
|
+
_context12.next = 6;
|
803
829
|
break;
|
804
830
|
}
|
805
|
-
return
|
831
|
+
return _context12.abrupt("return", null);
|
806
832
|
case 6:
|
807
833
|
partData = _objectSpread(_objectSpread({}, response.data), {}, {
|
808
834
|
headers: response.headers,
|
809
835
|
parameters: params
|
810
836
|
});
|
811
|
-
return
|
837
|
+
return _context12.abrupt("return", new _FileUploadPart.default(partData));
|
812
838
|
case 8:
|
813
839
|
case "end":
|
814
|
-
return
|
840
|
+
return _context12.stop();
|
815
841
|
}
|
816
|
-
},
|
842
|
+
}, _callee12);
|
817
843
|
}));
|
818
844
|
return function (_x7, _x8, _x9) {
|
819
|
-
return
|
845
|
+
return _ref14.apply(this, arguments);
|
820
846
|
};
|
821
847
|
}());
|
822
848
|
(0, _defineProperty2.default)(File, "_continueUpload", /*#__PURE__*/function () {
|
823
|
-
var
|
849
|
+
var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(path, partNumber, firstFileUploadPart, options) {
|
824
850
|
var params, response, partData;
|
825
|
-
return _regenerator.default.wrap(function
|
826
|
-
while (1) switch (
|
851
|
+
return _regenerator.default.wrap(function _callee13$(_context13) {
|
852
|
+
while (1) switch (_context13.prev = _context13.next) {
|
827
853
|
case 0:
|
828
854
|
params = {
|
829
855
|
action: 'put',
|
830
856
|
part: partNumber,
|
831
857
|
ref: firstFileUploadPart.ref
|
832
858
|
};
|
833
|
-
|
859
|
+
_context13.next = 3;
|
834
860
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(path)), 'POST', params, options);
|
835
861
|
case 3:
|
836
|
-
response =
|
862
|
+
response = _context13.sent;
|
837
863
|
if (response) {
|
838
|
-
|
864
|
+
_context13.next = 6;
|
839
865
|
break;
|
840
866
|
}
|
841
|
-
return
|
867
|
+
return _context13.abrupt("return", null);
|
842
868
|
case 6:
|
843
869
|
partData = _objectSpread(_objectSpread({}, response.data), {}, {
|
844
870
|
headers: response.headers,
|
845
871
|
parameters: params
|
846
872
|
});
|
847
|
-
return
|
873
|
+
return _context13.abrupt("return", new _FileUploadPart.default(partData));
|
848
874
|
case 8:
|
849
875
|
case "end":
|
850
|
-
return
|
876
|
+
return _context13.stop();
|
851
877
|
}
|
852
|
-
},
|
878
|
+
}, _callee13);
|
853
879
|
}));
|
854
880
|
return function (_x10, _x11, _x12, _x13) {
|
855
|
-
return
|
881
|
+
return _ref15.apply(this, arguments);
|
856
882
|
};
|
857
883
|
}());
|
858
884
|
(0, _defineProperty2.default)(File, "_completeUpload", /*#__PURE__*/function () {
|
859
|
-
var
|
885
|
+
var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(firstFileUploadPart, options) {
|
860
886
|
var params;
|
861
|
-
return _regenerator.default.wrap(function
|
862
|
-
while (1) switch (
|
887
|
+
return _regenerator.default.wrap(function _callee14$(_context14) {
|
888
|
+
while (1) switch (_context14.prev = _context14.next) {
|
863
889
|
case 0:
|
864
890
|
params = {
|
865
891
|
action: 'end',
|
866
892
|
ref: firstFileUploadPart.ref
|
867
893
|
};
|
868
|
-
return
|
894
|
+
return _context14.abrupt("return", _Api.default.sendRequest("/files/".concat(encodeURIComponent(firstFileUploadPart.path)), 'POST', params, options));
|
869
895
|
case 2:
|
870
896
|
case "end":
|
871
|
-
return
|
897
|
+
return _context14.stop();
|
872
898
|
}
|
873
|
-
},
|
899
|
+
}, _callee14);
|
874
900
|
}));
|
875
901
|
return function (_x14, _x15) {
|
876
|
-
return
|
902
|
+
return _ref16.apply(this, arguments);
|
877
903
|
};
|
878
904
|
}());
|
879
905
|
/**
|
880
906
|
* @note see File.copy() for list of supported params
|
881
907
|
*/
|
882
908
|
(0, _defineProperty2.default)(File, "uploadStream", /*#__PURE__*/function () {
|
883
|
-
var
|
909
|
+
var _ref17 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(destinationPath, readableStream, params, options) {
|
884
910
|
var firstFileUploadPart, file;
|
885
|
-
return _regenerator.default.wrap(function
|
886
|
-
while (1) switch (
|
911
|
+
return _regenerator.default.wrap(function _callee17$(_context17) {
|
912
|
+
while (1) switch (_context17.prev = _context17.next) {
|
887
913
|
case 0:
|
888
|
-
|
914
|
+
_context17.next = 2;
|
889
915
|
return File._openUpload(destinationPath, params, options);
|
890
916
|
case 2:
|
891
|
-
firstFileUploadPart =
|
917
|
+
firstFileUploadPart = _context17.sent;
|
892
918
|
if (firstFileUploadPart) {
|
893
|
-
|
919
|
+
_context17.next = 5;
|
894
920
|
break;
|
895
921
|
}
|
896
|
-
return
|
922
|
+
return _context17.abrupt("return");
|
897
923
|
case 5:
|
898
|
-
|
899
|
-
|
924
|
+
_context17.prev = 5;
|
925
|
+
_context17.next = 8;
|
900
926
|
return new Promise(function (resolve, reject) {
|
901
927
|
var part = 0;
|
902
928
|
var chunks = [];
|
@@ -906,17 +932,17 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
906
932
|
reject(error);
|
907
933
|
});
|
908
934
|
readableStream.on('data', /*#__PURE__*/function () {
|
909
|
-
var
|
935
|
+
var _ref18 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(chunk) {
|
910
936
|
var nextLength, excessLength, chunkBuffer, tailLength, lastChunkForPart, firstChunkForNextPart, buffer, nextFileUploadPart;
|
911
|
-
return _regenerator.default.wrap(function
|
912
|
-
while (1) switch (
|
937
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
938
|
+
while (1) switch (_context15.prev = _context15.next) {
|
913
939
|
case 0:
|
914
|
-
|
940
|
+
_context15.prev = 0;
|
915
941
|
nextLength = length + chunk.length;
|
916
942
|
excessLength = nextLength - firstFileUploadPart.partsize;
|
917
943
|
chunkBuffer = _safeBuffer.Buffer.from(chunk);
|
918
944
|
if (!(excessLength > 0)) {
|
919
|
-
|
945
|
+
_context15.next = 20;
|
920
946
|
break;
|
921
947
|
}
|
922
948
|
readableStream.pause();
|
@@ -927,90 +953,90 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
927
953
|
firstChunkForNextPart = chunkBuffer.subarray(tailLength);
|
928
954
|
chunks.push(lastChunkForPart);
|
929
955
|
buffer = _safeBuffer.Buffer.concat(chunks);
|
930
|
-
|
956
|
+
_context15.next = 13;
|
931
957
|
return File._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
932
958
|
case 13:
|
933
|
-
nextFileUploadPart =
|
959
|
+
nextFileUploadPart = _context15.sent;
|
934
960
|
concurrentUploads.push(_Api.default.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer));
|
935
961
|
chunks = [firstChunkForNextPart];
|
936
962
|
length = firstChunkForNextPart.length;
|
937
963
|
readableStream.resume();
|
938
|
-
|
964
|
+
_context15.next = 22;
|
939
965
|
break;
|
940
966
|
case 20:
|
941
967
|
chunks.push(chunkBuffer);
|
942
968
|
length += chunk.length;
|
943
969
|
case 22:
|
944
|
-
|
970
|
+
_context15.next = 27;
|
945
971
|
break;
|
946
972
|
case 24:
|
947
|
-
|
948
|
-
|
949
|
-
reject(
|
973
|
+
_context15.prev = 24;
|
974
|
+
_context15.t0 = _context15["catch"](0);
|
975
|
+
reject(_context15.t0);
|
950
976
|
case 27:
|
951
977
|
case "end":
|
952
|
-
return
|
978
|
+
return _context15.stop();
|
953
979
|
}
|
954
|
-
},
|
980
|
+
}, _callee15, null, [[0, 24]]);
|
955
981
|
}));
|
956
982
|
return function (_x20) {
|
957
|
-
return
|
983
|
+
return _ref18.apply(this, arguments);
|
958
984
|
};
|
959
985
|
}());
|
960
|
-
readableStream.on('end', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
986
|
+
readableStream.on('end', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
961
987
|
var buffer, nextFileUploadPart, response, createdFile;
|
962
|
-
return _regenerator.default.wrap(function
|
963
|
-
while (1) switch (
|
988
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
989
|
+
while (1) switch (_context16.prev = _context16.next) {
|
964
990
|
case 0:
|
965
|
-
|
991
|
+
_context16.prev = 0;
|
966
992
|
if (!(chunks.length > 0)) {
|
967
|
-
|
993
|
+
_context16.next = 7;
|
968
994
|
break;
|
969
995
|
}
|
970
996
|
buffer = _safeBuffer.Buffer.concat(chunks);
|
971
|
-
|
997
|
+
_context16.next = 5;
|
972
998
|
return File._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
973
999
|
case 5:
|
974
|
-
nextFileUploadPart =
|
1000
|
+
nextFileUploadPart = _context16.sent;
|
975
1001
|
concurrentUploads.push(_Api.default.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer));
|
976
1002
|
case 7:
|
977
|
-
|
1003
|
+
_context16.next = 9;
|
978
1004
|
return Promise.all(concurrentUploads);
|
979
1005
|
case 9:
|
980
|
-
|
1006
|
+
_context16.next = 11;
|
981
1007
|
return File._completeUpload(firstFileUploadPart, options);
|
982
1008
|
case 11:
|
983
|
-
response =
|
1009
|
+
response = _context16.sent;
|
984
1010
|
createdFile = new File(response.data, options);
|
985
1011
|
resolve(createdFile);
|
986
|
-
|
1012
|
+
_context16.next = 19;
|
987
1013
|
break;
|
988
1014
|
case 16:
|
989
|
-
|
990
|
-
|
991
|
-
reject(
|
1015
|
+
_context16.prev = 16;
|
1016
|
+
_context16.t0 = _context16["catch"](0);
|
1017
|
+
reject(_context16.t0);
|
992
1018
|
case 19:
|
993
1019
|
case "end":
|
994
|
-
return
|
1020
|
+
return _context16.stop();
|
995
1021
|
}
|
996
|
-
},
|
1022
|
+
}, _callee16, null, [[0, 16]]);
|
997
1023
|
})));
|
998
1024
|
});
|
999
1025
|
case 8:
|
1000
|
-
file =
|
1001
|
-
return
|
1026
|
+
file = _context17.sent;
|
1027
|
+
return _context17.abrupt("return", file);
|
1002
1028
|
case 12:
|
1003
|
-
|
1004
|
-
|
1005
|
-
errors.handleErrorResponse(
|
1029
|
+
_context17.prev = 12;
|
1030
|
+
_context17.t0 = _context17["catch"](5);
|
1031
|
+
errors.handleErrorResponse(_context17.t0);
|
1006
1032
|
case 15:
|
1007
1033
|
case "end":
|
1008
|
-
return
|
1034
|
+
return _context17.stop();
|
1009
1035
|
}
|
1010
|
-
},
|
1036
|
+
}, _callee17, null, [[5, 12]]);
|
1011
1037
|
}));
|
1012
1038
|
return function (_x16, _x17, _x18, _x19) {
|
1013
|
-
return
|
1039
|
+
return _ref17.apply(this, arguments);
|
1014
1040
|
};
|
1015
1041
|
}());
|
1016
1042
|
/**
|
@@ -1018,53 +1044,53 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1018
1044
|
* @note see File.copy() for list of supported params
|
1019
1045
|
*/
|
1020
1046
|
(0, _defineProperty2.default)(File, "uploadData", /*#__PURE__*/function () {
|
1021
|
-
var
|
1022
|
-
return _regenerator.default.wrap(function
|
1023
|
-
while (1) switch (
|
1047
|
+
var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(destinationPath, data, params, options) {
|
1048
|
+
return _regenerator.default.wrap(function _callee18$(_context18) {
|
1049
|
+
while (1) switch (_context18.prev = _context18.next) {
|
1024
1050
|
case 0:
|
1025
1051
|
if (data) {
|
1026
|
-
|
1052
|
+
_context18.next = 2;
|
1027
1053
|
break;
|
1028
1054
|
}
|
1029
1055
|
throw new errors.MissingParameterError('Upload data was not provided');
|
1030
1056
|
case 2:
|
1031
|
-
return
|
1057
|
+
return _context18.abrupt("return", File.uploadStream(destinationPath, _readableStream.default.from(data), params, options));
|
1032
1058
|
case 3:
|
1033
1059
|
case "end":
|
1034
|
-
return
|
1060
|
+
return _context18.stop();
|
1035
1061
|
}
|
1036
|
-
},
|
1062
|
+
}, _callee18);
|
1037
1063
|
}));
|
1038
1064
|
return function (_x21, _x22, _x23, _x24) {
|
1039
|
-
return
|
1065
|
+
return _ref20.apply(this, arguments);
|
1040
1066
|
};
|
1041
1067
|
}());
|
1042
1068
|
/**
|
1043
1069
|
* @note see File.copy() for list of supported params
|
1044
1070
|
*/
|
1045
1071
|
(0, _defineProperty2.default)(File, "uploadFile", /*#__PURE__*/function () {
|
1046
|
-
var
|
1047
|
-
var
|
1048
|
-
return _regenerator.default.wrap(function
|
1049
|
-
while (1) switch (
|
1072
|
+
var _ref21 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(destinationPath, sourceFilePath, params, options) {
|
1073
|
+
var _require4, openDiskFileReadStream, stream;
|
1074
|
+
return _regenerator.default.wrap(function _callee19$(_context19) {
|
1075
|
+
while (1) switch (_context19.prev = _context19.next) {
|
1050
1076
|
case 0:
|
1051
1077
|
if (!(0, _utils.isBrowser)()) {
|
1052
|
-
|
1078
|
+
_context19.next = 2;
|
1053
1079
|
break;
|
1054
1080
|
}
|
1055
1081
|
throw new errors.NotImplementedError('Disk file uploads are only available in a NodeJS environment');
|
1056
1082
|
case 2:
|
1057
|
-
|
1083
|
+
_require4 = require('../isomorphic/File.node.js'), openDiskFileReadStream = _require4.openDiskFileReadStream;
|
1058
1084
|
stream = openDiskFileReadStream(sourceFilePath);
|
1059
|
-
return
|
1085
|
+
return _context19.abrupt("return", File.uploadStream(destinationPath, stream, params, options));
|
1060
1086
|
case 5:
|
1061
1087
|
case "end":
|
1062
|
-
return
|
1088
|
+
return _context19.stop();
|
1063
1089
|
}
|
1064
|
-
},
|
1090
|
+
}, _callee19);
|
1065
1091
|
}));
|
1066
1092
|
return function (_x25, _x26, _x27, _x28) {
|
1067
|
-
return
|
1093
|
+
return _ref21.apply(this, arguments);
|
1068
1094
|
};
|
1069
1095
|
}());
|
1070
1096
|
// Parameters:
|
@@ -1083,102 +1109,102 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1083
1109
|
// structure - string - If copying folder, copy just the structure?
|
1084
1110
|
// with_rename - boolean - Allow file rename instead of overwrite?
|
1085
1111
|
(0, _defineProperty2.default)(File, "create", /*#__PURE__*/function () {
|
1086
|
-
var
|
1112
|
+
var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(path) {
|
1087
1113
|
var params,
|
1088
1114
|
options,
|
1089
1115
|
response,
|
1090
|
-
|
1091
|
-
return _regenerator.default.wrap(function
|
1092
|
-
while (1) switch (
|
1116
|
+
_args20 = arguments;
|
1117
|
+
return _regenerator.default.wrap(function _callee20$(_context20) {
|
1118
|
+
while (1) switch (_context20.prev = _context20.next) {
|
1093
1119
|
case 0:
|
1094
|
-
params =
|
1095
|
-
options =
|
1120
|
+
params = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {};
|
1121
|
+
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
1096
1122
|
if ((0, _utils.isObject)(params)) {
|
1097
|
-
|
1123
|
+
_context20.next = 4;
|
1098
1124
|
break;
|
1099
1125
|
}
|
1100
1126
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
1101
1127
|
case 4:
|
1102
1128
|
params['path'] = path;
|
1103
1129
|
if (params['path']) {
|
1104
|
-
|
1130
|
+
_context20.next = 7;
|
1105
1131
|
break;
|
1106
1132
|
}
|
1107
1133
|
throw new errors.MissingParameterError('Parameter missing: path');
|
1108
1134
|
case 7:
|
1109
1135
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
1110
|
-
|
1136
|
+
_context20.next = 9;
|
1111
1137
|
break;
|
1112
1138
|
}
|
1113
1139
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(params['path'])));
|
1114
1140
|
case 9:
|
1115
1141
|
if (!(params['action'] && !(0, _utils.isString)(params['action']))) {
|
1116
|
-
|
1142
|
+
_context20.next = 11;
|
1117
1143
|
break;
|
1118
1144
|
}
|
1119
1145
|
throw new errors.InvalidParameterError("Bad parameter: action must be of type String, received ".concat((0, _utils.getType)(params['action'])));
|
1120
1146
|
case 11:
|
1121
1147
|
if (!(params['length'] && !(0, _utils.isInt)(params['length']))) {
|
1122
|
-
|
1148
|
+
_context20.next = 13;
|
1123
1149
|
break;
|
1124
1150
|
}
|
1125
1151
|
throw new errors.InvalidParameterError("Bad parameter: length must be of type Int, received ".concat((0, _utils.getType)(params['length'])));
|
1126
1152
|
case 13:
|
1127
1153
|
if (!(params['part'] && !(0, _utils.isInt)(params['part']))) {
|
1128
|
-
|
1154
|
+
_context20.next = 15;
|
1129
1155
|
break;
|
1130
1156
|
}
|
1131
1157
|
throw new errors.InvalidParameterError("Bad parameter: part must be of type Int, received ".concat((0, _utils.getType)(params['part'])));
|
1132
1158
|
case 15:
|
1133
1159
|
if (!(params['parts'] && !(0, _utils.isInt)(params['parts']))) {
|
1134
|
-
|
1160
|
+
_context20.next = 17;
|
1135
1161
|
break;
|
1136
1162
|
}
|
1137
1163
|
throw new errors.InvalidParameterError("Bad parameter: parts must be of type Int, received ".concat((0, _utils.getType)(params['parts'])));
|
1138
1164
|
case 17:
|
1139
1165
|
if (!(params['provided_mtime'] && !(0, _utils.isString)(params['provided_mtime']))) {
|
1140
|
-
|
1166
|
+
_context20.next = 19;
|
1141
1167
|
break;
|
1142
1168
|
}
|
1143
1169
|
throw new errors.InvalidParameterError("Bad parameter: provided_mtime must be of type String, received ".concat((0, _utils.getType)(params['provided_mtime'])));
|
1144
1170
|
case 19:
|
1145
1171
|
if (!(params['ref'] && !(0, _utils.isString)(params['ref']))) {
|
1146
|
-
|
1172
|
+
_context20.next = 21;
|
1147
1173
|
break;
|
1148
1174
|
}
|
1149
1175
|
throw new errors.InvalidParameterError("Bad parameter: ref must be of type String, received ".concat((0, _utils.getType)(params['ref'])));
|
1150
1176
|
case 21:
|
1151
1177
|
if (!(params['restart'] && !(0, _utils.isInt)(params['restart']))) {
|
1152
|
-
|
1178
|
+
_context20.next = 23;
|
1153
1179
|
break;
|
1154
1180
|
}
|
1155
1181
|
throw new errors.InvalidParameterError("Bad parameter: restart must be of type Int, received ".concat((0, _utils.getType)(params['restart'])));
|
1156
1182
|
case 23:
|
1157
1183
|
if (!(params['size'] && !(0, _utils.isInt)(params['size']))) {
|
1158
|
-
|
1184
|
+
_context20.next = 25;
|
1159
1185
|
break;
|
1160
1186
|
}
|
1161
1187
|
throw new errors.InvalidParameterError("Bad parameter: size must be of type Int, received ".concat((0, _utils.getType)(params['size'])));
|
1162
1188
|
case 25:
|
1163
1189
|
if (!(params['structure'] && !(0, _utils.isString)(params['structure']))) {
|
1164
|
-
|
1190
|
+
_context20.next = 27;
|
1165
1191
|
break;
|
1166
1192
|
}
|
1167
1193
|
throw new errors.InvalidParameterError("Bad parameter: structure must be of type String, received ".concat((0, _utils.getType)(params['structure'])));
|
1168
1194
|
case 27:
|
1169
|
-
|
1195
|
+
_context20.next = 29;
|
1170
1196
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(params['path'])), 'POST', params, options);
|
1171
1197
|
case 29:
|
1172
|
-
response =
|
1173
|
-
return
|
1198
|
+
response = _context20.sent;
|
1199
|
+
return _context20.abrupt("return", new File(response === null || response === void 0 ? void 0 : response.data, options));
|
1174
1200
|
case 31:
|
1175
1201
|
case "end":
|
1176
|
-
return
|
1202
|
+
return _context20.stop();
|
1177
1203
|
}
|
1178
|
-
},
|
1204
|
+
}, _callee20);
|
1179
1205
|
}));
|
1180
1206
|
return function (_x29) {
|
1181
|
-
return
|
1207
|
+
return _ref22.apply(this, arguments);
|
1182
1208
|
};
|
1183
1209
|
}());
|
1184
1210
|
// Parameters:
|
@@ -1187,54 +1213,54 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1187
1213
|
// with_previews - boolean - Include file preview information?
|
1188
1214
|
// with_priority_color - boolean - Include file priority color information?
|
1189
1215
|
(0, _defineProperty2.default)(File, "find", /*#__PURE__*/function () {
|
1190
|
-
var
|
1216
|
+
var _ref23 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(path) {
|
1191
1217
|
var params,
|
1192
1218
|
options,
|
1193
1219
|
response,
|
1194
|
-
|
1195
|
-
return _regenerator.default.wrap(function
|
1196
|
-
while (1) switch (
|
1220
|
+
_args21 = arguments;
|
1221
|
+
return _regenerator.default.wrap(function _callee21$(_context21) {
|
1222
|
+
while (1) switch (_context21.prev = _context21.next) {
|
1197
1223
|
case 0:
|
1198
|
-
params =
|
1199
|
-
options =
|
1224
|
+
params = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {};
|
1225
|
+
options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
|
1200
1226
|
if ((0, _utils.isObject)(params)) {
|
1201
|
-
|
1227
|
+
_context21.next = 4;
|
1202
1228
|
break;
|
1203
1229
|
}
|
1204
1230
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
1205
1231
|
case 4:
|
1206
1232
|
params['path'] = path;
|
1207
1233
|
if (params['path']) {
|
1208
|
-
|
1234
|
+
_context21.next = 7;
|
1209
1235
|
break;
|
1210
1236
|
}
|
1211
1237
|
throw new errors.MissingParameterError('Parameter missing: path');
|
1212
1238
|
case 7:
|
1213
1239
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
1214
|
-
|
1240
|
+
_context21.next = 9;
|
1215
1241
|
break;
|
1216
1242
|
}
|
1217
1243
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(params['path'])));
|
1218
1244
|
case 9:
|
1219
1245
|
if (!(params['preview_size'] && !(0, _utils.isString)(params['preview_size']))) {
|
1220
|
-
|
1246
|
+
_context21.next = 11;
|
1221
1247
|
break;
|
1222
1248
|
}
|
1223
1249
|
throw new errors.InvalidParameterError("Bad parameter: preview_size must be of type String, received ".concat((0, _utils.getType)(params['preview_size'])));
|
1224
1250
|
case 11:
|
1225
|
-
|
1251
|
+
_context21.next = 13;
|
1226
1252
|
return _Api.default.sendRequest("/file_actions/metadata/".concat(encodeURIComponent(params['path'])), 'GET', params, options);
|
1227
1253
|
case 13:
|
1228
|
-
response =
|
1229
|
-
return
|
1254
|
+
response = _context21.sent;
|
1255
|
+
return _context21.abrupt("return", new File(response === null || response === void 0 ? void 0 : response.data, options));
|
1230
1256
|
case 15:
|
1231
1257
|
case "end":
|
1232
|
-
return
|
1258
|
+
return _context21.stop();
|
1233
1259
|
}
|
1234
|
-
},
|
1260
|
+
}, _callee21);
|
1235
1261
|
}));
|
1236
1262
|
return function (_x30) {
|
1237
|
-
return
|
1263
|
+
return _ref23.apply(this, arguments);
|
1238
1264
|
};
|
1239
1265
|
}());
|
1240
1266
|
(0, _defineProperty2.default)(File, "get", function (path) {
|