files.com 1.0.206 → 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.206
1
+ 1.0.207
@@ -1047,37 +1047,45 @@ 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
1091
  return function (_x14) {
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.0.206",
3
+ "version": "1.0.207",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
@@ -95,37 +95,45 @@ class File {
95
95
  readableStream.on('error', error => { reject(error) })
96
96
 
97
97
  readableStream.on('data', async chunk => {
98
- length += chunk.length
98
+ try {
99
+ length += chunk.length
99
100
 
100
- if (length > fileUploadPart.partsize) {
101
- readableStream.pause()
101
+ if (length > fileUploadPart.partsize) {
102
+ readableStream.pause()
102
103
 
103
- const buffer = Buffer.concat(chunks)
104
- const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, fileUploadPart)
104
+ const buffer = Buffer.concat(chunks)
105
+ const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, fileUploadPart)
105
106
 
106
- await Api.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer)
107
+ await Api.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer)
107
108
 
108
- chunks = []
109
- length = 0
109
+ chunks = []
110
+ length = 0
110
111
 
111
- readableStream.resume()
112
- }
112
+ readableStream.resume()
113
+ }
113
114
 
114
- chunks.push(Buffer.from(chunk))
115
+ chunks.push(Buffer.from(chunk))
116
+ } catch (error) {
117
+ reject(error)
118
+ }
115
119
  })
116
120
 
117
121
  readableStream.on('end', async () => {
118
- if (chunks.length > 0) {
119
- const buffer = Buffer.concat(chunks)
120
- 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)
121
126
 
122
- await Api.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer)
123
- }
127
+ await Api.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer)
128
+ }
124
129
 
125
- const response = await File._completeUpload(fileUploadPart)
126
- const createdFile = new File(response.data)
130
+ const response = await File._completeUpload(fileUploadPart)
131
+ const createdFile = new File(response.data)
127
132
 
128
- resolve(createdFile)
133
+ resolve(createdFile)
134
+ } catch (error) {
135
+ reject(error)
136
+ }
129
137
  })
130
138
  })
131
139