files.com 1.0.205 → 1.0.206

Sign up to get free protection for your applications and to get access to all the features.
package/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.205
1
+ 1.0.206
@@ -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;
@@ -1080,7 +1080,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1080
1080
  }, _callee14);
1081
1081
  }));
1082
1082
 
1083
- return function (_x12) {
1083
+ return function (_x14) {
1084
1084
  return _ref17.apply(this, arguments);
1085
1085
  };
1086
1086
  }());
@@ -1139,12 +1139,12 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1139
1139
  }, _callee16, null, [[5, 12]]);
1140
1140
  }));
1141
1141
 
1142
- return function (_x10, _x11) {
1142
+ return function (_x11, _x12, _x13) {
1143
1143
  return _ref16.apply(this, arguments);
1144
1144
  };
1145
1145
  }());
1146
1146
  (0, _defineProperty2.default)(File, "uploadData", /*#__PURE__*/function () {
1147
- var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(destinationPath, data) {
1147
+ var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(destinationPath, data, params) {
1148
1148
  return _regenerator.default.wrap(function _callee17$(_context17) {
1149
1149
  while (1) {
1150
1150
  switch (_context17.prev = _context17.next) {
@@ -1157,7 +1157,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1157
1157
  throw new errors.MissingParameterError('Upload data was not provided');
1158
1158
 
1159
1159
  case 2:
1160
- return _context17.abrupt("return", File.uploadStream(destinationPath, _readableStream.default.from(data)));
1160
+ return _context17.abrupt("return", File.uploadStream(destinationPath, _readableStream.default.from(data), params));
1161
1161
 
1162
1162
  case 3:
1163
1163
  case "end":
@@ -1167,12 +1167,12 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1167
1167
  }, _callee17);
1168
1168
  }));
1169
1169
 
1170
- return function (_x13, _x14) {
1170
+ return function (_x15, _x16, _x17) {
1171
1171
  return _ref19.apply(this, arguments);
1172
1172
  };
1173
1173
  }());
1174
1174
  (0, _defineProperty2.default)(File, "uploadFile", /*#__PURE__*/function () {
1175
- var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(destinationPath, sourceFilePath) {
1175
+ var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(destinationPath, sourceFilePath, params) {
1176
1176
  var _require3, openDiskFileReadStream, stream;
1177
1177
 
1178
1178
  return _regenerator.default.wrap(function _callee18$(_context18) {
@@ -1189,7 +1189,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1189
1189
  case 2:
1190
1190
  _require3 = require('../isomorphic/File.node.js'), openDiskFileReadStream = _require3.openDiskFileReadStream;
1191
1191
  stream = openDiskFileReadStream(sourceFilePath);
1192
- return _context18.abrupt("return", File.uploadStream(destinationPath, stream));
1192
+ return _context18.abrupt("return", File.uploadStream(destinationPath, stream, params));
1193
1193
 
1194
1194
  case 5:
1195
1195
  case "end":
@@ -1199,7 +1199,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1199
1199
  }, _callee18);
1200
1200
  }));
1201
1201
 
1202
- return function (_x15, _x16) {
1202
+ return function (_x18, _x19, _x20) {
1203
1203
  return _ref20.apply(this, arguments);
1204
1204
  };
1205
1205
  }());
@@ -1329,7 +1329,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1329
1329
  }, _callee19);
1330
1330
  }));
1331
1331
 
1332
- return function (_x17) {
1332
+ return function (_x21) {
1333
1333
  return _ref21.apply(this, arguments);
1334
1334
  };
1335
1335
  }());
@@ -1395,7 +1395,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1395
1395
  }, _callee20);
1396
1396
  }));
1397
1397
 
1398
- return function (_x18) {
1398
+ return function (_x22) {
1399
1399
  return _ref22.apply(this, arguments);
1400
1400
  };
1401
1401
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.0.205",
3
+ "version": "1.0.206",
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
@@ -134,16 +137,20 @@ class File {
134
137
 
135
138
  /**
136
139
  * data - string, Buffer, Stream, any object implementing Symbol.iterator or Symbol.asyncIterator
140
+ * @note see File.copy() for list of supported params
137
141
  */
138
- static uploadData = async (destinationPath, data) => {
142
+ static uploadData = async (destinationPath, data, params) => {
139
143
  if (!data) {
140
144
  throw new errors.MissingParameterError('Upload data was not provided')
141
145
  }
142
146
 
143
- return File.uploadStream(destinationPath, Readable.from(data))
147
+ return File.uploadStream(destinationPath, Readable.from(data), params)
144
148
  }
145
149
 
146
- static uploadFile = async (destinationPath, sourceFilePath) => {
150
+ /**
151
+ * @note see File.copy() for list of supported params
152
+ */
153
+ static uploadFile = async (destinationPath, sourceFilePath, params) => {
147
154
  if (isBrowser()) {
148
155
  throw new errors.NotImplementedError('Disk file uploads are only available in a NodeJS environment')
149
156
  }
@@ -151,7 +158,7 @@ class File {
151
158
  const { openDiskFileReadStream } = require('../isomorphic/File.node.js')
152
159
  const stream = openDiskFileReadStream(sourceFilePath)
153
160
 
154
- return File.uploadStream(destinationPath, stream)
161
+ return File.uploadStream(destinationPath, stream, params)
155
162
  }
156
163
 
157
164
  downloadToStream = async writableStream => {