code7-leia 0.2.13 → 0.2.17

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,53 @@ 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
+ console.log('sanitizedPath: ', sanitizedPath);
2200
+ formData.append('file', blob, sanitizedPath || 'default_filename');
2201
+ console.log('formData: ', formData);
2202
+ console.log('file: ', file);
2199
2203
  queryParams = pressets.length ? new URLSearchParams({
2200
2204
  tags: pressets.join(',')
2201
2205
  }).toString() : '';
2202
2206
  url = queryParams ? "/upload/" + id + "?token=" + token + "&" + queryParams : "/upload/" + id + "?token=" + token;
2203
- _context4.next = 12;
2207
+ _context4.next = 16;
2204
2208
  return call(api.post, url, formData, {
2205
2209
  headers: {
2206
2210
  'Content-Type': 'multipart/form-data'
2207
2211
  }
2208
2212
  });
2209
- case 12:
2210
- _context4.next = 14;
2213
+ case 16:
2214
+ _context4.next = 18;
2211
2215
  return call(api.get, "/training/" + id + "?token=" + token);
2212
- case 14:
2216
+ case 18:
2213
2217
  _yield$call4 = _context4.sent;
2214
2218
  data = _yield$call4.data;
2215
- _context4.next = 18;
2219
+ _context4.next = 22;
2216
2220
  return put(uploadFilesActionSuccess({
2217
2221
  files: data.files
2218
2222
  }));
2219
- case 18:
2220
- _context4.next = 24;
2223
+ case 22:
2224
+ _context4.next = 28;
2221
2225
  break;
2222
- case 20:
2223
- _context4.prev = 20;
2226
+ case 24:
2227
+ _context4.prev = 24;
2224
2228
  _context4.t0 = _context4["catch"](1);
2225
2229
  toast.error({
2226
2230
  title: t.toast.uploadFile.fail.title,
2227
2231
  description: t.toast.uploadFile.fail.description
2228
2232
  });
2229
2233
  console.log('-----------uploadFilesSaga.error------------------->', _context4.t0);
2230
- case 24:
2231
- _context4.prev = 24;
2232
- _context4.next = 27;
2233
- return put(commonLoadingFinish());
2234
- case 27:
2235
- return _context4.finish(24);
2236
2234
  case 28:
2235
+ _context4.prev = 28;
2236
+ _context4.next = 31;
2237
+ return put(commonLoadingFinish());
2238
+ case 31:
2239
+ return _context4.finish(28);
2240
+ case 32:
2237
2241
  case "end":
2238
2242
  return _context4.stop();
2239
2243
  }
2240
- }, _marked4, null, [[1, 20, 24, 28]]);
2244
+ }, _marked4, null, [[1, 24, 28, 32]]);
2241
2245
  }
2242
2246
  function TrainingSaga(action) {
2243
2247
  var t, _action$payload5, id, pressets, token, tag, queryParams, _yield$call5, data;