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