files.com 1.0.412 → 1.0.414
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/_VERSION +1 -1
- package/lib/Api.js +30 -18
- package/lib/Files.js +1 -1
- package/lib/isomorphic/File.node.js +21 -13
- package/lib/models/ActionNotificationExport.js +8 -5
- package/lib/models/ApiKey.js +8 -5
- package/lib/models/As2Partner.js +8 -5
- package/lib/models/As2Station.js +8 -5
- package/lib/models/Automation.js +8 -5
- package/lib/models/AutomationRun.js +8 -5
- package/lib/models/Behavior.js +15 -9
- package/lib/models/Bundle.js +8 -5
- package/lib/models/BundleNotification.js +8 -5
- package/lib/models/Clickwrap.js +8 -5
- package/lib/models/ExternalEvent.js +8 -5
- package/lib/models/File.js +212 -131
- package/lib/models/FileComment.js +8 -5
- package/lib/models/FileMigration.js +8 -5
- package/lib/models/Folder.js +14 -9
- package/lib/models/FormFieldSet.js +8 -5
- package/lib/models/GpgKey.js +8 -5
- package/lib/models/Group.js +8 -5
- package/lib/models/History.js +22 -13
- package/lib/models/HistoryExport.js +8 -5
- package/lib/models/Invoice.js +8 -5
- package/lib/models/Lock.js +15 -9
- package/lib/models/Message.js +8 -5
- package/lib/models/MessageComment.js +8 -5
- package/lib/models/MessageCommentReaction.js +8 -5
- package/lib/models/MessageReaction.js +8 -5
- package/lib/models/Notification.js +8 -5
- package/lib/models/Payment.js +8 -5
- package/lib/models/Priority.js +8 -5
- package/lib/models/Project.js +8 -5
- package/lib/models/PublicKey.js +8 -5
- package/lib/models/RemoteServer.js +15 -9
- package/lib/models/Request.js +8 -5
- package/lib/models/SftpHostKey.js +8 -5
- package/lib/models/ShareGroup.js +8 -5
- package/lib/models/Snapshot.js +8 -5
- package/lib/models/SsoStrategy.js +8 -5
- package/lib/models/Style.js +8 -5
- package/lib/models/User.js +8 -5
- package/lib/models/UserRequest.js +8 -5
- package/package.json +1 -1
- package/src/Files.js +1 -1
- package/src/models/File.js +86 -44
- package/test/src/index.js +30 -3
package/lib/models/File.js
CHANGED
@@ -20,7 +20,7 @@ var _utils = require("../utils");
|
|
20
20
|
var _FileAction = _interopRequireDefault(require("./FileAction"));
|
21
21
|
var _FileUploadPart = _interopRequireDefault(require("./FileUploadPart"));
|
22
22
|
var _excluded = ["determinePartUploadUri"];
|
23
|
-
var _class
|
23
|
+
var _class;
|
24
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
25
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
26
26
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
@@ -29,11 +29,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
29
29
|
* Class File
|
30
30
|
*/
|
31
31
|
var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
32
|
-
var _this = this
|
33
|
-
_ref,
|
34
|
-
_ref3,
|
35
|
-
_ref4,
|
36
|
-
_ref5;
|
32
|
+
var _this = this;
|
37
33
|
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
38
34
|
var _options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
39
35
|
(0, _classCallCheck2.default)(this, File);
|
@@ -42,8 +38,8 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
42
38
|
(0, _defineProperty2.default)(this, "isLoaded", function () {
|
43
39
|
return !!_this.attributes.path;
|
44
40
|
});
|
45
|
-
(0, _defineProperty2.default)(this, "downloadToStream", function (
|
46
|
-
|
41
|
+
(0, _defineProperty2.default)(this, "downloadToStream", /*#__PURE__*/function () {
|
42
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(writableStream) {
|
47
43
|
var downloadUri, _require, saveUrlToStream;
|
48
44
|
return _regenerator.default.wrap(function _callee$(_context) {
|
49
45
|
while (1) switch (_context.prev = _context.next) {
|
@@ -68,8 +64,11 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
68
64
|
return _context.stop();
|
69
65
|
}
|
70
66
|
}, _callee);
|
71
|
-
}))
|
72
|
-
|
67
|
+
}));
|
68
|
+
return function (_x) {
|
69
|
+
return _ref.apply(this, arguments);
|
70
|
+
};
|
71
|
+
}());
|
73
72
|
(0, _defineProperty2.default)(this, "downloadToString", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
74
73
|
var downloadUri, _require2, saveUrlToString;
|
75
74
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
@@ -96,8 +95,8 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
96
95
|
}
|
97
96
|
}, _callee2);
|
98
97
|
})));
|
99
|
-
(0, _defineProperty2.default)(this, "downloadToFile", function (
|
100
|
-
|
98
|
+
(0, _defineProperty2.default)(this, "downloadToFile", /*#__PURE__*/function () {
|
99
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(destinationPath) {
|
101
100
|
var downloadUri, _require3, saveUrlToFile;
|
102
101
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
103
102
|
while (1) switch (_context3.prev = _context3.next) {
|
@@ -122,10 +121,13 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
122
121
|
return _context3.stop();
|
123
122
|
}
|
124
123
|
}, _callee3);
|
125
|
-
}))
|
126
|
-
|
127
|
-
|
128
|
-
|
124
|
+
}));
|
125
|
+
return function (_x2) {
|
126
|
+
return _ref3.apply(this, arguments);
|
127
|
+
};
|
128
|
+
}());
|
129
|
+
(0, _defineProperty2.default)(this, "copyTo", /*#__PURE__*/function () {
|
130
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(destinationFilePath, options) {
|
129
131
|
var params;
|
130
132
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
131
133
|
while (1) switch (_context4.prev = _context4.next) {
|
@@ -139,10 +141,13 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
139
141
|
return _context4.stop();
|
140
142
|
}
|
141
143
|
}, _callee4);
|
142
|
-
}))
|
143
|
-
|
144
|
-
|
145
|
-
|
144
|
+
}));
|
145
|
+
return function (_x3, _x4) {
|
146
|
+
return _ref4.apply(this, arguments);
|
147
|
+
};
|
148
|
+
}());
|
149
|
+
(0, _defineProperty2.default)(this, "moveTo", /*#__PURE__*/function () {
|
150
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(destinationFilePath, options) {
|
146
151
|
var params;
|
147
152
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
148
153
|
while (1) switch (_context5.prev = _context5.next) {
|
@@ -156,8 +161,11 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
156
161
|
return _context5.stop();
|
157
162
|
}
|
158
163
|
}, _callee5);
|
159
|
-
}))
|
160
|
-
|
164
|
+
}));
|
165
|
+
return function (_x5, _x6) {
|
166
|
+
return _ref5.apply(this, arguments);
|
167
|
+
};
|
168
|
+
}());
|
161
169
|
// string # File/Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
|
162
170
|
(0, _defineProperty2.default)(this, "getPath", function () {
|
163
171
|
return _this.attributes.path;
|
@@ -807,8 +815,8 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
807
815
|
this.options = _objectSpread({}, _options);
|
808
816
|
});
|
809
817
|
_class = File;
|
810
|
-
(0, _defineProperty2.default)(File, "_openUpload", function (
|
811
|
-
|
818
|
+
(0, _defineProperty2.default)(File, "_openUpload", /*#__PURE__*/function () {
|
819
|
+
var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(path, paramsRaw, options) {
|
812
820
|
var params, response, partData;
|
813
821
|
return _regenerator.default.wrap(function _callee12$(_context12) {
|
814
822
|
while (1) switch (_context12.prev = _context12.next) {
|
@@ -836,10 +844,13 @@ _class = File;
|
|
836
844
|
return _context12.stop();
|
837
845
|
}
|
838
846
|
}, _callee12);
|
839
|
-
}))
|
840
|
-
|
841
|
-
|
842
|
-
|
847
|
+
}));
|
848
|
+
return function (_x7, _x8, _x9) {
|
849
|
+
return _ref14.apply(this, arguments);
|
850
|
+
};
|
851
|
+
}());
|
852
|
+
(0, _defineProperty2.default)(File, "_continueUpload", /*#__PURE__*/function () {
|
853
|
+
var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(path, partNumber, firstFileUploadPart, options) {
|
843
854
|
var params, response, partData;
|
844
855
|
return _regenerator.default.wrap(function _callee13$(_context13) {
|
845
856
|
while (1) switch (_context13.prev = _context13.next) {
|
@@ -869,10 +880,13 @@ _class = File;
|
|
869
880
|
return _context13.stop();
|
870
881
|
}
|
871
882
|
}, _callee13);
|
872
|
-
}))
|
873
|
-
|
874
|
-
|
875
|
-
|
883
|
+
}));
|
884
|
+
return function (_x10, _x11, _x12, _x13) {
|
885
|
+
return _ref15.apply(this, arguments);
|
886
|
+
};
|
887
|
+
}());
|
888
|
+
(0, _defineProperty2.default)(File, "_completeUpload", /*#__PURE__*/function () {
|
889
|
+
var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(firstFileUploadPart, options) {
|
876
890
|
var params;
|
877
891
|
return _regenerator.default.wrap(function _callee14$(_context14) {
|
878
892
|
while (1) switch (_context14.prev = _context14.next) {
|
@@ -887,13 +901,16 @@ _class = File;
|
|
887
901
|
return _context14.stop();
|
888
902
|
}
|
889
903
|
}, _callee14);
|
890
|
-
}))
|
891
|
-
|
904
|
+
}));
|
905
|
+
return function (_x14, _x15) {
|
906
|
+
return _ref16.apply(this, arguments);
|
907
|
+
};
|
908
|
+
}());
|
892
909
|
/**
|
893
910
|
* @note see File.copy() for list of supported params
|
894
911
|
*/
|
895
|
-
(0, _defineProperty2.default)(File, "uploadStream", function (
|
896
|
-
|
912
|
+
(0, _defineProperty2.default)(File, "uploadStream", /*#__PURE__*/function () {
|
913
|
+
var _ref17 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(destinationPath, readableStream, params, optionsRaw) {
|
897
914
|
var _ref18, determinePartUploadUriRaw, options, firstFileUploadPart, determinePartUploadUri, file;
|
898
915
|
return _regenerator.default.wrap(function _callee17$(_context17) {
|
899
916
|
while (1) switch (_context17.prev = _context17.next) {
|
@@ -915,120 +932,169 @@ _class = File;
|
|
915
932
|
_context17.prev = 7;
|
916
933
|
_context17.next = 10;
|
917
934
|
return new Promise(function (resolve, reject) {
|
918
|
-
var _ref19;
|
919
935
|
var part = 0;
|
920
936
|
var chunks = [];
|
921
937
|
var length = 0;
|
922
938
|
var concurrentUploads = [];
|
939
|
+
var chunkBuffer = null;
|
940
|
+
var streamEnded = false;
|
941
|
+
var handleStreamEnd = /*#__PURE__*/function () {
|
942
|
+
var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
943
|
+
var _options$getAgentForU, buffer, nextFileUploadPart, upload_uri, agent, response, createdFile;
|
944
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
945
|
+
while (1) switch (_context15.prev = _context15.next) {
|
946
|
+
case 0:
|
947
|
+
if (!(chunkBuffer !== null || !streamEnded)) {
|
948
|
+
_context15.next = 2;
|
949
|
+
break;
|
950
|
+
}
|
951
|
+
return _context15.abrupt("return");
|
952
|
+
case 2:
|
953
|
+
_context15.prev = 2;
|
954
|
+
if (!(chunks.length > 0)) {
|
955
|
+
_context15.next = 11;
|
956
|
+
break;
|
957
|
+
}
|
958
|
+
buffer = _safeBuffer.Buffer.concat(chunks);
|
959
|
+
_context15.next = 7;
|
960
|
+
return _class._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
961
|
+
case 7:
|
962
|
+
nextFileUploadPart = _context15.sent;
|
963
|
+
upload_uri = determinePartUploadUri(nextFileUploadPart); // instantiate an httpsAgent dynamically if needed
|
964
|
+
agent = ((_options$getAgentForU = options.getAgentForUrl) === null || _options$getAgentForU === void 0 ? void 0 : _options$getAgentForU.call(options, upload_uri)) || (options === null || options === void 0 ? void 0 : options.agent);
|
965
|
+
concurrentUploads.push(_Api.default.sendFilePart(upload_uri, 'PUT', buffer, {
|
966
|
+
agent: agent
|
967
|
+
}));
|
968
|
+
case 11:
|
969
|
+
_context15.next = 13;
|
970
|
+
return Promise.all(concurrentUploads);
|
971
|
+
case 13:
|
972
|
+
_context15.next = 15;
|
973
|
+
return _class._completeUpload(firstFileUploadPart, options);
|
974
|
+
case 15:
|
975
|
+
response = _context15.sent;
|
976
|
+
createdFile = new _class(response.data, options);
|
977
|
+
resolve(createdFile);
|
978
|
+
_context15.next = 23;
|
979
|
+
break;
|
980
|
+
case 20:
|
981
|
+
_context15.prev = 20;
|
982
|
+
_context15.t0 = _context15["catch"](2);
|
983
|
+
reject(_context15.t0);
|
984
|
+
case 23:
|
985
|
+
case "end":
|
986
|
+
return _context15.stop();
|
987
|
+
}
|
988
|
+
}, _callee15, null, [[2, 20]]);
|
989
|
+
}));
|
990
|
+
return function handleStreamEnd() {
|
991
|
+
return _ref19.apply(this, arguments);
|
992
|
+
};
|
993
|
+
}();
|
923
994
|
readableStream.on('error', function (error) {
|
924
995
|
reject(error);
|
925
996
|
});
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
997
|
+
|
998
|
+
// note that for a network stream, each chunk is typically less than partsize * 2, but
|
999
|
+
// if a stream has been created based on very large data, it's possible for a chunk to
|
1000
|
+
// contain the entire file and we could get a single chunk with length >= partsize * 3
|
1001
|
+
readableStream.on('data', /*#__PURE__*/function () {
|
1002
|
+
var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(chunk) {
|
1003
|
+
var excessLength, _options$getAgentForU2, lengthForEndOfCurrentPart, lastChunkForCurrentPart, chunkBufferAfterCurrentPart, buffer, nextFileUploadPart, upload_uri, agent, uploadPromise, isNextChunkAtLeastOnePart;
|
1004
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
1005
|
+
while (1) switch (_context16.prev = _context16.next) {
|
931
1006
|
case 0:
|
932
|
-
|
933
|
-
|
934
|
-
excessLength = nextLength - firstFileUploadPart.partsize;
|
1007
|
+
_context16.prev = 0;
|
1008
|
+
excessLength = length + chunk.length - firstFileUploadPart.partsize;
|
935
1009
|
chunkBuffer = _safeBuffer.Buffer.from(chunk);
|
936
1010
|
if (!(excessLength > 0)) {
|
937
|
-
|
1011
|
+
_context16.next = 30;
|
938
1012
|
break;
|
939
1013
|
}
|
940
1014
|
readableStream.pause();
|
941
|
-
|
1015
|
+
case 5:
|
1016
|
+
if (!chunkBuffer) {
|
1017
|
+
_context16.next = 27;
|
1018
|
+
break;
|
1019
|
+
}
|
942
1020
|
// the amount to append this last part with to make it exactly the full partsize
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
chunks.push(
|
1021
|
+
lengthForEndOfCurrentPart = chunkBuffer.length - excessLength;
|
1022
|
+
lastChunkForCurrentPart = chunkBuffer.subarray(0, lengthForEndOfCurrentPart);
|
1023
|
+
chunkBufferAfterCurrentPart = chunkBuffer.subarray(lengthForEndOfCurrentPart);
|
1024
|
+
chunks.push(lastChunkForCurrentPart);
|
947
1025
|
buffer = _safeBuffer.Buffer.concat(chunks);
|
948
|
-
|
1026
|
+
_context16.next = 13;
|
949
1027
|
return _class._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
950
1028
|
case 13:
|
951
|
-
nextFileUploadPart =
|
1029
|
+
nextFileUploadPart = _context16.sent;
|
952
1030
|
upload_uri = determinePartUploadUri(nextFileUploadPart); // instantiate an httpsAgent dynamically if needed
|
953
|
-
agent = ((_options$
|
1031
|
+
agent = ((_options$getAgentForU2 = options.getAgentForUrl) === null || _options$getAgentForU2 === void 0 ? void 0 : _options$getAgentForU2.call(options, upload_uri)) || (options === null || options === void 0 ? void 0 : options.agent);
|
954
1032
|
uploadPromise = _Api.default.sendFilePart(upload_uri, 'PUT', buffer, {
|
955
1033
|
agent: agent
|
956
1034
|
});
|
957
1035
|
if (!firstFileUploadPart.parallel_parts) {
|
958
|
-
|
1036
|
+
_context16.next = 21;
|
959
1037
|
break;
|
960
1038
|
}
|
961
1039
|
concurrentUploads.push(uploadPromise);
|
962
|
-
|
1040
|
+
_context16.next = 23;
|
963
1041
|
break;
|
964
1042
|
case 21:
|
965
|
-
|
1043
|
+
_context16.next = 23;
|
966
1044
|
return uploadPromise;
|
967
1045
|
case 23:
|
968
|
-
|
969
|
-
|
1046
|
+
// determine if the remainder of the excess chunk data is too large to be a single part
|
1047
|
+
isNextChunkAtLeastOnePart = chunkBufferAfterCurrentPart.length >= firstFileUploadPart.partsize; // the excess data contains >= 1 full part, so we'll loop again to enqueue
|
1048
|
+
// the next part for upload and continue processing any excess beyond that
|
1049
|
+
if (isNextChunkAtLeastOnePart) {
|
1050
|
+
chunks = [];
|
1051
|
+
length = 0;
|
1052
|
+
chunkBuffer = chunkBufferAfterCurrentPart;
|
1053
|
+
excessLength = chunkBuffer.length - firstFileUploadPart.partsize;
|
1054
|
+
// the excess data is less than a full part, so we'll enqueue it
|
1055
|
+
} else if (chunkBufferAfterCurrentPart.length > 0) {
|
1056
|
+
chunks = [chunkBufferAfterCurrentPart];
|
1057
|
+
length = chunkBufferAfterCurrentPart.length;
|
1058
|
+
chunkBuffer = null;
|
1059
|
+
} else {
|
1060
|
+
chunkBuffer = null;
|
1061
|
+
}
|
1062
|
+
_context16.next = 5;
|
1063
|
+
break;
|
1064
|
+
case 27:
|
970
1065
|
readableStream.resume();
|
971
|
-
|
1066
|
+
_context16.next = 33;
|
972
1067
|
break;
|
973
|
-
case
|
1068
|
+
case 30:
|
974
1069
|
chunks.push(chunkBuffer);
|
975
1070
|
length += chunk.length;
|
976
|
-
|
977
|
-
|
1071
|
+
chunkBuffer = null;
|
1072
|
+
case 33:
|
1073
|
+
if (streamEnded) {
|
1074
|
+
handleStreamEnd();
|
1075
|
+
}
|
1076
|
+
_context16.next = 39;
|
978
1077
|
break;
|
979
|
-
case
|
980
|
-
|
981
|
-
|
982
|
-
reject(
|
983
|
-
case
|
1078
|
+
case 36:
|
1079
|
+
_context16.prev = 36;
|
1080
|
+
_context16.t0 = _context16["catch"](0);
|
1081
|
+
reject(_context16.t0);
|
1082
|
+
case 39:
|
984
1083
|
case "end":
|
985
|
-
return
|
1084
|
+
return _context16.stop();
|
986
1085
|
}
|
987
|
-
},
|
988
|
-
}))
|
1086
|
+
}, _callee16, null, [[0, 36]]);
|
1087
|
+
}));
|
1088
|
+
return function (_x20) {
|
1089
|
+
return _ref20.apply(this, arguments);
|
1090
|
+
};
|
1091
|
+
}());
|
1092
|
+
|
1093
|
+
// note that this event may occur while there is still data being processed above
|
1094
|
+
readableStream.on('end', function () {
|
1095
|
+
streamEnded = true;
|
1096
|
+
handleStreamEnd();
|
989
1097
|
});
|
990
|
-
readableStream.on('end', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
991
|
-
var _options$getAgentForU2, buffer, nextFileUploadPart, upload_uri, agent, response, createdFile;
|
992
|
-
return _regenerator.default.wrap(function _callee16$(_context16) {
|
993
|
-
while (1) switch (_context16.prev = _context16.next) {
|
994
|
-
case 0:
|
995
|
-
_context16.prev = 0;
|
996
|
-
if (!(chunks.length > 0)) {
|
997
|
-
_context16.next = 9;
|
998
|
-
break;
|
999
|
-
}
|
1000
|
-
buffer = _safeBuffer.Buffer.concat(chunks);
|
1001
|
-
_context16.next = 5;
|
1002
|
-
return _class._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
1003
|
-
case 5:
|
1004
|
-
nextFileUploadPart = _context16.sent;
|
1005
|
-
upload_uri = determinePartUploadUri(nextFileUploadPart); // instantiate an httpsAgent dynamically if needed
|
1006
|
-
agent = ((_options$getAgentForU2 = options.getAgentForUrl) === null || _options$getAgentForU2 === void 0 ? void 0 : _options$getAgentForU2.call(options, upload_uri)) || (options === null || options === void 0 ? void 0 : options.agent);
|
1007
|
-
concurrentUploads.push(_Api.default.sendFilePart(upload_uri, 'PUT', buffer, {
|
1008
|
-
agent: agent
|
1009
|
-
}));
|
1010
|
-
case 9:
|
1011
|
-
_context16.next = 11;
|
1012
|
-
return Promise.all(concurrentUploads);
|
1013
|
-
case 11:
|
1014
|
-
_context16.next = 13;
|
1015
|
-
return _class._completeUpload(firstFileUploadPart, options);
|
1016
|
-
case 13:
|
1017
|
-
response = _context16.sent;
|
1018
|
-
createdFile = new _class(response.data, options);
|
1019
|
-
resolve(createdFile);
|
1020
|
-
_context16.next = 21;
|
1021
|
-
break;
|
1022
|
-
case 18:
|
1023
|
-
_context16.prev = 18;
|
1024
|
-
_context16.t0 = _context16["catch"](0);
|
1025
|
-
reject(_context16.t0);
|
1026
|
-
case 21:
|
1027
|
-
case "end":
|
1028
|
-
return _context16.stop();
|
1029
|
-
}
|
1030
|
-
}, _callee16, null, [[0, 18]]);
|
1031
|
-
})));
|
1032
1098
|
});
|
1033
1099
|
case 10:
|
1034
1100
|
file = _context17.sent;
|
@@ -1042,14 +1108,17 @@ _class = File;
|
|
1042
1108
|
return _context17.stop();
|
1043
1109
|
}
|
1044
1110
|
}, _callee17, null, [[7, 14]]);
|
1045
|
-
}))
|
1046
|
-
|
1111
|
+
}));
|
1112
|
+
return function (_x16, _x17, _x18, _x19) {
|
1113
|
+
return _ref17.apply(this, arguments);
|
1114
|
+
};
|
1115
|
+
}());
|
1047
1116
|
/**
|
1048
1117
|
* data - string, Buffer, Stream, any object implementing Symbol.iterator or Symbol.asyncIterator
|
1049
1118
|
* @note see File.copy() for list of supported params
|
1050
1119
|
*/
|
1051
|
-
(0, _defineProperty2.default)(File, "uploadData", function (
|
1052
|
-
|
1120
|
+
(0, _defineProperty2.default)(File, "uploadData", /*#__PURE__*/function () {
|
1121
|
+
var _ref21 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(destinationPath, data, params, options) {
|
1053
1122
|
return _regenerator.default.wrap(function _callee18$(_context18) {
|
1054
1123
|
while (1) switch (_context18.prev = _context18.next) {
|
1055
1124
|
case 0:
|
@@ -1065,13 +1134,16 @@ _class = File;
|
|
1065
1134
|
return _context18.stop();
|
1066
1135
|
}
|
1067
1136
|
}, _callee18);
|
1068
|
-
}))
|
1069
|
-
|
1137
|
+
}));
|
1138
|
+
return function (_x21, _x22, _x23, _x24) {
|
1139
|
+
return _ref21.apply(this, arguments);
|
1140
|
+
};
|
1141
|
+
}());
|
1070
1142
|
/**
|
1071
1143
|
* @note see File.copy() for list of supported params
|
1072
1144
|
*/
|
1073
|
-
(0, _defineProperty2.default)(File, "uploadFile", function (
|
1074
|
-
|
1145
|
+
(0, _defineProperty2.default)(File, "uploadFile", /*#__PURE__*/function () {
|
1146
|
+
var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(destinationPath, sourceFilePath, params, options) {
|
1075
1147
|
var _require4, openDiskFileReadStream, stream;
|
1076
1148
|
return _regenerator.default.wrap(function _callee19$(_context19) {
|
1077
1149
|
while (1) switch (_context19.prev = _context19.next) {
|
@@ -1090,8 +1162,11 @@ _class = File;
|
|
1090
1162
|
return _context19.stop();
|
1091
1163
|
}
|
1092
1164
|
}, _callee19);
|
1093
|
-
}))
|
1094
|
-
|
1165
|
+
}));
|
1166
|
+
return function (_x25, _x26, _x27, _x28) {
|
1167
|
+
return _ref22.apply(this, arguments);
|
1168
|
+
};
|
1169
|
+
}());
|
1095
1170
|
// Parameters:
|
1096
1171
|
// path (required) - string - Path to operate on.
|
1097
1172
|
// action - string - The action to perform. Can be `append`, `attachment`, `end`, `upload`, `put`, or may not exist
|
@@ -1107,8 +1182,8 @@ _class = File;
|
|
1107
1182
|
// size - int64 - Size of file.
|
1108
1183
|
// structure - string - If copying folder, copy just the structure?
|
1109
1184
|
// with_rename - boolean - Allow file rename instead of overwrite?
|
1110
|
-
(0, _defineProperty2.default)(File, "create", function (
|
1111
|
-
|
1185
|
+
(0, _defineProperty2.default)(File, "create", /*#__PURE__*/function () {
|
1186
|
+
var _ref23 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(path) {
|
1112
1187
|
var params,
|
1113
1188
|
options,
|
1114
1189
|
response,
|
@@ -1201,15 +1276,18 @@ _class = File;
|
|
1201
1276
|
return _context20.stop();
|
1202
1277
|
}
|
1203
1278
|
}, _callee20);
|
1204
|
-
}))
|
1205
|
-
|
1279
|
+
}));
|
1280
|
+
return function (_x29) {
|
1281
|
+
return _ref23.apply(this, arguments);
|
1282
|
+
};
|
1283
|
+
}());
|
1206
1284
|
// Parameters:
|
1207
1285
|
// path (required) - string - Path to operate on.
|
1208
1286
|
// preview_size - string - Request a preview size. Can be `small` (default), `large`, `xlarge`, or `pdf`.
|
1209
1287
|
// with_previews - boolean - Include file preview information?
|
1210
1288
|
// with_priority_color - boolean - Include file priority color information?
|
1211
|
-
(0, _defineProperty2.default)(File, "find", function (
|
1212
|
-
|
1289
|
+
(0, _defineProperty2.default)(File, "find", /*#__PURE__*/function () {
|
1290
|
+
var _ref24 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(path) {
|
1213
1291
|
var params,
|
1214
1292
|
options,
|
1215
1293
|
response,
|
@@ -1254,8 +1332,11 @@ _class = File;
|
|
1254
1332
|
return _context21.stop();
|
1255
1333
|
}
|
1256
1334
|
}, _callee21);
|
1257
|
-
}))
|
1258
|
-
|
1335
|
+
}));
|
1336
|
+
return function (_x30) {
|
1337
|
+
return _ref24.apply(this, arguments);
|
1338
|
+
};
|
1339
|
+
}());
|
1259
1340
|
(0, _defineProperty2.default)(File, "get", function (path) {
|
1260
1341
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1261
1342
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
@@ -14,7 +14,7 @@ var _Api = _interopRequireDefault(require("../Api"));
|
|
14
14
|
var errors = _interopRequireWildcard(require("../Errors"));
|
15
15
|
var _Logger = _interopRequireDefault(require("../Logger"));
|
16
16
|
var _utils = require("../utils");
|
17
|
-
var _class
|
17
|
+
var _class;
|
18
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
20
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
@@ -217,8 +217,8 @@ _class = FileComment;
|
|
217
217
|
// cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
218
218
|
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
219
219
|
// path (required) - string - Path to operate on.
|
220
|
-
(0, _defineProperty2.default)(FileComment, "listFor", function (
|
221
|
-
|
220
|
+
(0, _defineProperty2.default)(FileComment, "listFor", /*#__PURE__*/function () {
|
221
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(path) {
|
222
222
|
var _response$data;
|
223
223
|
var params,
|
224
224
|
options,
|
@@ -272,8 +272,11 @@ _class = FileComment;
|
|
272
272
|
return _context3.stop();
|
273
273
|
}
|
274
274
|
}, _callee3);
|
275
|
-
}))
|
276
|
-
|
275
|
+
}));
|
276
|
+
return function (_x) {
|
277
|
+
return _ref5.apply(this, arguments);
|
278
|
+
};
|
279
|
+
}());
|
277
280
|
// Parameters:
|
278
281
|
// body (required) - string - Comment body.
|
279
282
|
// path (required) - string - File path.
|
@@ -14,7 +14,7 @@ var _Api = _interopRequireDefault(require("../Api"));
|
|
14
14
|
var errors = _interopRequireWildcard(require("../Errors"));
|
15
15
|
var _Logger = _interopRequireDefault(require("../Logger"));
|
16
16
|
var _utils = require("../utils");
|
17
|
-
var _class
|
17
|
+
var _class;
|
18
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
20
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
@@ -84,8 +84,8 @@ var FileMigration = /*#__PURE__*/(0, _createClass2.default)(function FileMigrati
|
|
84
84
|
_class = FileMigration;
|
85
85
|
// Parameters:
|
86
86
|
// id (required) - int64 - File Migration ID.
|
87
|
-
(0, _defineProperty2.default)(FileMigration, "find", function (
|
88
|
-
|
87
|
+
(0, _defineProperty2.default)(FileMigration, "find", /*#__PURE__*/function () {
|
88
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(id) {
|
89
89
|
var params,
|
90
90
|
options,
|
91
91
|
response,
|
@@ -124,8 +124,11 @@ _class = FileMigration;
|
|
124
124
|
return _context.stop();
|
125
125
|
}
|
126
126
|
}, _callee);
|
127
|
-
}))
|
128
|
-
|
127
|
+
}));
|
128
|
+
return function (_x) {
|
129
|
+
return _ref3.apply(this, arguments);
|
130
|
+
};
|
131
|
+
}());
|
129
132
|
(0, _defineProperty2.default)(FileMigration, "get", function (id) {
|
130
133
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
131
134
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|