code7-leia 0.2.13 → 0.2.16

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.
@@ -2183,7 +2183,7 @@ function testSaga(action) {
2183
2183
  }, _marked3, null, [[0, 12, 15, 19]]);
2184
2184
  }
2185
2185
  function uploadFilesSaga(action) {
2186
- var t, _action$payload4, id, file, pressets, token, blob, formData, queryParams, url, _yield$call4, data;
2186
+ var t, _action$payload4, id, file, pressets, token, blob, formData, sanitizedPath, queryParams, url, _yield$call4, data;
2187
2187
  return _regeneratorRuntime().wrap(function uploadFilesSaga$(_context4) {
2188
2188
  while (1) switch (_context4.prev = _context4.next) {
2189
2189
  case 0:
@@ -2195,49 +2195,50 @@ function uploadFilesSaga(action) {
2195
2195
  _action$payload4 = action.payload, id = _action$payload4.id, file = _action$payload4.file, pressets = _action$payload4.pressets, token = _action$payload4.token;
2196
2196
  blob = new Blob([file.content]);
2197
2197
  formData = new FormData();
2198
- formData.append('file', blob, file.properties.path);
2198
+ sanitizedPath = file.properties.path.replace(/^\/+|\/+$/g, '');
2199
+ formData.append('file', blob, sanitizedPath || 'default_filename');
2199
2200
  queryParams = pressets.length ? new URLSearchParams({
2200
2201
  tags: pressets.join(',')
2201
2202
  }).toString() : '';
2202
2203
  url = queryParams ? "/upload/" + id + "?token=" + token + "&" + queryParams : "/upload/" + id + "?token=" + token;
2203
- _context4.next = 12;
2204
+ _context4.next = 13;
2204
2205
  return call(api.post, url, formData, {
2205
2206
  headers: {
2206
2207
  'Content-Type': 'multipart/form-data'
2207
2208
  }
2208
2209
  });
2209
- case 12:
2210
- _context4.next = 14;
2210
+ case 13:
2211
+ _context4.next = 15;
2211
2212
  return call(api.get, "/training/" + id + "?token=" + token);
2212
- case 14:
2213
+ case 15:
2213
2214
  _yield$call4 = _context4.sent;
2214
2215
  data = _yield$call4.data;
2215
- _context4.next = 18;
2216
+ _context4.next = 19;
2216
2217
  return put(uploadFilesActionSuccess({
2217
2218
  files: data.files
2218
2219
  }));
2219
- case 18:
2220
- _context4.next = 24;
2220
+ case 19:
2221
+ _context4.next = 25;
2221
2222
  break;
2222
- case 20:
2223
- _context4.prev = 20;
2223
+ case 21:
2224
+ _context4.prev = 21;
2224
2225
  _context4.t0 = _context4["catch"](1);
2225
2226
  toast.error({
2226
2227
  title: t.toast.uploadFile.fail.title,
2227
2228
  description: t.toast.uploadFile.fail.description
2228
2229
  });
2229
2230
  console.log('-----------uploadFilesSaga.error------------------->', _context4.t0);
2230
- case 24:
2231
- _context4.prev = 24;
2232
- _context4.next = 27;
2231
+ case 25:
2232
+ _context4.prev = 25;
2233
+ _context4.next = 28;
2233
2234
  return put(commonLoadingFinish());
2234
- case 27:
2235
- return _context4.finish(24);
2236
2235
  case 28:
2236
+ return _context4.finish(25);
2237
+ case 29:
2237
2238
  case "end":
2238
2239
  return _context4.stop();
2239
2240
  }
2240
- }, _marked4, null, [[1, 20, 24, 28]]);
2241
+ }, _marked4, null, [[1, 21, 25, 29]]);
2241
2242
  }
2242
2243
  function TrainingSaga(action) {
2243
2244
  var t, _action$payload5, id, pressets, token, tag, queryParams, _yield$call5, data;