files.com 1.0.204 → 1.0.207

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 CHANGED
@@ -1 +1 @@
1
- 1.0.204
1
+ 1.0.207
@@ -562,6 +562,7 @@ await Site.update({
562
562
  * `user_requests_notify_admins` (boolean): Send email to site admins when a user request is received?
563
563
  * `ftp_enabled` (boolean): Is FTP enabled?
564
564
  * `sftp_enabled` (boolean): Is SFTP enabled?
565
+ * `bundle_watermark_value` (object): Preview watermark settings applied to all bundle items. Uses the same keys as Behavior.value
565
566
  * `allowed_2fa_method_sms` (boolean): Is SMS two factor authentication allowed?
566
567
  * `allowed_2fa_method_u2f` (boolean): Is U2F two factor authentication allowed?
567
568
  * `allowed_2fa_method_totp` (boolean): Is TOTP two factor authentication allowed?
@@ -14,9 +14,7 @@
14
14
  "deleted_files_storage": "65536",
15
15
  "deleted_files_counted_in_minimum": "65536",
16
16
  "root_storage": "65536",
17
- "usage_by_top_level_dir": [
18
- ""
19
- ]
17
+ "usage_by_top_level_dir": ""
20
18
  }
21
19
  ```
22
20
 
@@ -30,7 +28,7 @@
30
28
  * `deleted_files_storage` (int64): GB of Files Native Storage used on this day for files that have been deleted and are stored as backups.
31
29
  * `deleted_files_counted_in_minimum` (int64): GB of Files Native Storage used on this day for files that have been permanently deleted but were uploaded less than 30 days ago, and are still billable.
32
30
  * `root_storage` (int64): GB of Files Native Storage used for the root folder. Included here because this value will not be part of `usage_by_top_level_dir`
33
- * `usage_by_top_level_dir` (array): Usage broken down by each top-level folder
31
+ * `usage_by_top_level_dir` (object): Usage broken down by each top-level folder
34
32
 
35
33
  ---
36
34
 
@@ -900,15 +900,15 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
900
900
  this.options = _objectSpread({}, options);
901
901
  });
902
902
  (0, _defineProperty2.default)(File, "_openUpload", /*#__PURE__*/function () {
903
- var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(path) {
903
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(path, paramsRaw) {
904
904
  var params, response, partData;
905
905
  return _regenerator.default.wrap(function _callee11$(_context11) {
906
906
  while (1) {
907
907
  switch (_context11.prev = _context11.next) {
908
908
  case 0:
909
- params = {
909
+ params = _objectSpread(_objectSpread({}, paramsRaw), {}, {
910
910
  action: 'put'
911
- };
911
+ });
912
912
  _context11.next = 3;
913
913
  return _Api.default.sendRequest("/files/".concat(encodeURIComponent(path)), 'POST', params);
914
914
 
@@ -937,7 +937,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
937
937
  }, _callee11);
938
938
  }));
939
939
 
940
- return function (_x5) {
940
+ return function (_x5, _x6) {
941
941
  return _ref13.apply(this, arguments);
942
942
  };
943
943
  }());
@@ -981,7 +981,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
981
981
  }, _callee12);
982
982
  }));
983
983
 
984
- return function (_x6, _x7, _x8) {
984
+ return function (_x7, _x8, _x9) {
985
985
  return _ref14.apply(this, arguments);
986
986
  };
987
987
  }());
@@ -1006,19 +1006,19 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1006
1006
  }, _callee13);
1007
1007
  }));
1008
1008
 
1009
- return function (_x9) {
1009
+ return function (_x10) {
1010
1010
  return _ref15.apply(this, arguments);
1011
1011
  };
1012
1012
  }());
1013
1013
  (0, _defineProperty2.default)(File, "uploadStream", /*#__PURE__*/function () {
1014
- var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(destinationPath, readableStream) {
1014
+ var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(destinationPath, readableStream, params) {
1015
1015
  var fileUploadPart, file;
1016
1016
  return _regenerator.default.wrap(function _callee16$(_context16) {
1017
1017
  while (1) {
1018
1018
  switch (_context16.prev = _context16.next) {
1019
1019
  case 0:
1020
1020
  _context16.next = 2;
1021
- return File._openUpload(destinationPath);
1021
+ return File._openUpload(destinationPath, params);
1022
1022
 
1023
1023
  case 2:
1024
1024
  fileUploadPart = _context16.sent;
@@ -1047,40 +1047,48 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1047
1047
  while (1) {
1048
1048
  switch (_context14.prev = _context14.next) {
1049
1049
  case 0:
1050
+ _context14.prev = 0;
1050
1051
  length += chunk.length;
1051
1052
 
1052
1053
  if (!(length > fileUploadPart.partsize)) {
1053
- _context14.next = 12;
1054
+ _context14.next = 13;
1054
1055
  break;
1055
1056
  }
1056
1057
 
1057
1058
  readableStream.pause();
1058
1059
  buffer = _safeBuffer.Buffer.concat(chunks);
1059
- _context14.next = 6;
1060
+ _context14.next = 7;
1060
1061
  return File._continueUpload(destinationPath, ++part, fileUploadPart);
1061
1062
 
1062
- case 6:
1063
+ case 7:
1063
1064
  nextFileUploadPart = _context14.sent;
1064
- _context14.next = 9;
1065
+ _context14.next = 10;
1065
1066
  return _Api.default.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer);
1066
1067
 
1067
- case 9:
1068
+ case 10:
1068
1069
  chunks = [];
1069
1070
  length = 0;
1070
1071
  readableStream.resume();
1071
1072
 
1072
- case 12:
1073
+ case 13:
1073
1074
  chunks.push(_safeBuffer.Buffer.from(chunk));
1075
+ _context14.next = 19;
1076
+ break;
1074
1077
 
1075
- case 13:
1078
+ case 16:
1079
+ _context14.prev = 16;
1080
+ _context14.t0 = _context14["catch"](0);
1081
+ reject(_context14.t0);
1082
+
1083
+ case 19:
1076
1084
  case "end":
1077
1085
  return _context14.stop();
1078
1086
  }
1079
1087
  }
1080
- }, _callee14);
1088
+ }, _callee14, null, [[0, 16]]);
1081
1089
  }));
1082
1090
 
1083
- return function (_x12) {
1091
+ return function (_x14) {
1084
1092
  return _ref17.apply(this, arguments);
1085
1093
  };
1086
1094
  }());
@@ -1090,35 +1098,44 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1090
1098
  while (1) {
1091
1099
  switch (_context15.prev = _context15.next) {
1092
1100
  case 0:
1101
+ _context15.prev = 0;
1102
+
1093
1103
  if (!(chunks.length > 0)) {
1094
- _context15.next = 7;
1104
+ _context15.next = 8;
1095
1105
  break;
1096
1106
  }
1097
1107
 
1098
1108
  buffer = _safeBuffer.Buffer.concat(chunks);
1099
- _context15.next = 4;
1109
+ _context15.next = 5;
1100
1110
  return File._continueUpload(destinationPath, ++part, fileUploadPart);
1101
1111
 
1102
- case 4:
1112
+ case 5:
1103
1113
  nextFileUploadPart = _context15.sent;
1104
- _context15.next = 7;
1114
+ _context15.next = 8;
1105
1115
  return _Api.default.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer);
1106
1116
 
1107
- case 7:
1108
- _context15.next = 9;
1117
+ case 8:
1118
+ _context15.next = 10;
1109
1119
  return File._completeUpload(fileUploadPart);
1110
1120
 
1111
- case 9:
1121
+ case 10:
1112
1122
  response = _context15.sent;
1113
1123
  createdFile = new File(response.data);
1114
1124
  resolve(createdFile);
1125
+ _context15.next = 18;
1126
+ break;
1127
+
1128
+ case 15:
1129
+ _context15.prev = 15;
1130
+ _context15.t0 = _context15["catch"](0);
1131
+ reject(_context15.t0);
1115
1132
 
1116
- case 12:
1133
+ case 18:
1117
1134
  case "end":
1118
1135
  return _context15.stop();
1119
1136
  }
1120
1137
  }
1121
- }, _callee15);
1138
+ }, _callee15, null, [[0, 15]]);
1122
1139
  })));
1123
1140
  });
1124
1141
 
@@ -1139,12 +1156,12 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1139
1156
  }, _callee16, null, [[5, 12]]);
1140
1157
  }));
1141
1158
 
1142
- return function (_x10, _x11) {
1159
+ return function (_x11, _x12, _x13) {
1143
1160
  return _ref16.apply(this, arguments);
1144
1161
  };
1145
1162
  }());
1146
1163
  (0, _defineProperty2.default)(File, "uploadData", /*#__PURE__*/function () {
1147
- var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(destinationPath, data) {
1164
+ var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(destinationPath, data, params) {
1148
1165
  return _regenerator.default.wrap(function _callee17$(_context17) {
1149
1166
  while (1) {
1150
1167
  switch (_context17.prev = _context17.next) {
@@ -1157,7 +1174,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1157
1174
  throw new errors.MissingParameterError('Upload data was not provided');
1158
1175
 
1159
1176
  case 2:
1160
- return _context17.abrupt("return", File.uploadStream(destinationPath, _readableStream.default.from(data)));
1177
+ return _context17.abrupt("return", File.uploadStream(destinationPath, _readableStream.default.from(data), params));
1161
1178
 
1162
1179
  case 3:
1163
1180
  case "end":
@@ -1167,12 +1184,12 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1167
1184
  }, _callee17);
1168
1185
  }));
1169
1186
 
1170
- return function (_x13, _x14) {
1187
+ return function (_x15, _x16, _x17) {
1171
1188
  return _ref19.apply(this, arguments);
1172
1189
  };
1173
1190
  }());
1174
1191
  (0, _defineProperty2.default)(File, "uploadFile", /*#__PURE__*/function () {
1175
- var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(destinationPath, sourceFilePath) {
1192
+ var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(destinationPath, sourceFilePath, params) {
1176
1193
  var _require3, openDiskFileReadStream, stream;
1177
1194
 
1178
1195
  return _regenerator.default.wrap(function _callee18$(_context18) {
@@ -1189,7 +1206,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1189
1206
  case 2:
1190
1207
  _require3 = require('../isomorphic/File.node.js'), openDiskFileReadStream = _require3.openDiskFileReadStream;
1191
1208
  stream = openDiskFileReadStream(sourceFilePath);
1192
- return _context18.abrupt("return", File.uploadStream(destinationPath, stream));
1209
+ return _context18.abrupt("return", File.uploadStream(destinationPath, stream, params));
1193
1210
 
1194
1211
  case 5:
1195
1212
  case "end":
@@ -1199,7 +1216,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1199
1216
  }, _callee18);
1200
1217
  }));
1201
1218
 
1202
- return function (_x15, _x16) {
1219
+ return function (_x18, _x19, _x20) {
1203
1220
  return _ref20.apply(this, arguments);
1204
1221
  };
1205
1222
  }());
@@ -1329,7 +1346,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1329
1346
  }, _callee19);
1330
1347
  }));
1331
1348
 
1332
- return function (_x17) {
1349
+ return function (_x21) {
1333
1350
  return _ref21.apply(this, arguments);
1334
1351
  };
1335
1352
  }());
@@ -1395,7 +1412,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1395
1412
  }, _callee20);
1396
1413
  }));
1397
1414
 
1398
- return function (_x18) {
1415
+ return function (_x22) {
1399
1416
  return _ref22.apply(this, arguments);
1400
1417
  };
1401
1418
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.0.204",
3
+ "version": "1.0.207",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
@@ -28,8 +28,8 @@ class File {
28
28
  }
29
29
 
30
30
  isLoaded = () => !!this.attributes.path
31
- static _openUpload = async path => {
32
- const params = { action: 'put' }
31
+ static _openUpload = async (path, paramsRaw) => {
32
+ const params = { ...paramsRaw, action: 'put' }
33
33
  const response = await Api.sendRequest(`/files/${encodeURIComponent(path)}`, 'POST', params)
34
34
 
35
35
  if (!response) {
@@ -76,8 +76,11 @@ class File {
76
76
  return Api.sendRequest(`/files/${encodeURIComponent(fileUploadPart.path)}`, 'POST', params)
77
77
  }
78
78
 
79
- static uploadStream = async (destinationPath, readableStream) => {
80
- const fileUploadPart = await File._openUpload(destinationPath)
79
+ /**
80
+ * @note see File.copy() for list of supported params
81
+ */
82
+ static uploadStream = async (destinationPath, readableStream, params) => {
83
+ const fileUploadPart = await File._openUpload(destinationPath, params)
81
84
 
82
85
  if (!fileUploadPart) {
83
86
  return
@@ -92,37 +95,45 @@ class File {
92
95
  readableStream.on('error', error => { reject(error) })
93
96
 
94
97
  readableStream.on('data', async chunk => {
95
- length += chunk.length
98
+ try {
99
+ length += chunk.length
96
100
 
97
- if (length > fileUploadPart.partsize) {
98
- readableStream.pause()
101
+ if (length > fileUploadPart.partsize) {
102
+ readableStream.pause()
99
103
 
100
- const buffer = Buffer.concat(chunks)
101
- const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, fileUploadPart)
104
+ const buffer = Buffer.concat(chunks)
105
+ const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, fileUploadPart)
102
106
 
103
- await Api.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer)
107
+ await Api.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer)
104
108
 
105
- chunks = []
106
- length = 0
109
+ chunks = []
110
+ length = 0
107
111
 
108
- readableStream.resume()
109
- }
112
+ readableStream.resume()
113
+ }
110
114
 
111
- chunks.push(Buffer.from(chunk))
115
+ chunks.push(Buffer.from(chunk))
116
+ } catch (error) {
117
+ reject(error)
118
+ }
112
119
  })
113
120
 
114
121
  readableStream.on('end', async () => {
115
- if (chunks.length > 0) {
116
- const buffer = Buffer.concat(chunks)
117
- const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, fileUploadPart)
122
+ try {
123
+ if (chunks.length > 0) {
124
+ const buffer = Buffer.concat(chunks)
125
+ const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, fileUploadPart)
118
126
 
119
- await Api.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer)
120
- }
127
+ await Api.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer)
128
+ }
121
129
 
122
- const response = await File._completeUpload(fileUploadPart)
123
- const createdFile = new File(response.data)
130
+ const response = await File._completeUpload(fileUploadPart)
131
+ const createdFile = new File(response.data)
124
132
 
125
- resolve(createdFile)
133
+ resolve(createdFile)
134
+ } catch (error) {
135
+ reject(error)
136
+ }
126
137
  })
127
138
  })
128
139
 
@@ -134,16 +145,20 @@ class File {
134
145
 
135
146
  /**
136
147
  * data - string, Buffer, Stream, any object implementing Symbol.iterator or Symbol.asyncIterator
148
+ * @note see File.copy() for list of supported params
137
149
  */
138
- static uploadData = async (destinationPath, data) => {
150
+ static uploadData = async (destinationPath, data, params) => {
139
151
  if (!data) {
140
152
  throw new errors.MissingParameterError('Upload data was not provided')
141
153
  }
142
154
 
143
- return File.uploadStream(destinationPath, Readable.from(data))
155
+ return File.uploadStream(destinationPath, Readable.from(data), params)
144
156
  }
145
157
 
146
- static uploadFile = async (destinationPath, sourceFilePath) => {
158
+ /**
159
+ * @note see File.copy() for list of supported params
160
+ */
161
+ static uploadFile = async (destinationPath, sourceFilePath, params) => {
147
162
  if (isBrowser()) {
148
163
  throw new errors.NotImplementedError('Disk file uploads are only available in a NodeJS environment')
149
164
  }
@@ -151,7 +166,7 @@ class File {
151
166
  const { openDiskFileReadStream } = require('../isomorphic/File.node.js')
152
167
  const stream = openDiskFileReadStream(sourceFilePath)
153
168
 
154
- return File.uploadStream(destinationPath, stream)
169
+ return File.uploadStream(destinationPath, stream, params)
155
170
  }
156
171
 
157
172
  downloadToStream = async writableStream => {
@@ -498,6 +498,7 @@ class Site {
498
498
  // user_requests_notify_admins - boolean - Send email to site admins when a user request is received?
499
499
  // ftp_enabled - boolean - Is FTP enabled?
500
500
  // sftp_enabled - boolean - Is SFTP enabled?
501
+ // bundle_watermark_value - object - Preview watermark settings applied to all bundle items. Uses the same keys as Behavior.value
501
502
  // allowed_2fa_method_sms - boolean - Is SMS two factor authentication allowed?
502
503
  // allowed_2fa_method_u2f - boolean - Is U2F two factor authentication allowed?
503
504
  // allowed_2fa_method_totp - boolean - Is TOTP two factor authentication allowed?
@@ -53,7 +53,7 @@ class UsageDailySnapshot {
53
53
  // int64 # GB of Files Native Storage used for the root folder. Included here because this value will not be part of `usage_by_top_level_dir`
54
54
  getRootStorage = () => this.attributes.root_storage
55
55
 
56
- // array # Usage broken down by each top-level folder
56
+ // object # Usage broken down by each top-level folder
57
57
  getUsageByTopLevelDir = () => this.attributes.usage_by_top_level_dir
58
58
 
59
59