@uploadcare/upload-client 6.0.1-alpha.3 → 6.0.1-alpha.5

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.
@@ -465,7 +465,8 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
465
465
  jsonerrors: 1
466
466
  }),
467
467
  headers: {
468
- 'X-UC-User-Agent': getUserAgent({ publicKey, integration, userAgent })
468
+ 'X-UC-User-Agent': getUserAgent({ publicKey, integration, userAgent }),
469
+ 'content-type': 'multipart/form-data'
469
470
  },
470
471
  data: buildFormData({
471
472
  file: {
@@ -489,7 +489,8 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
489
489
  jsonerrors: 1
490
490
  }),
491
491
  headers: {
492
- 'X-UC-User-Agent': getUserAgent({ publicKey, integration, userAgent })
492
+ 'X-UC-User-Agent': getUserAgent({ publicKey, integration, userAgent }),
493
+ 'content-type': 'multipart/form-data'
493
494
  },
494
495
  data: buildFormData({
495
496
  file: {
@@ -258,13 +258,13 @@ const isReactNativeUri = (uri) => {
258
258
  };
259
259
 
260
260
  const getFileOptions = ({ name }) => name ? [name] : [];
261
- const transformFile = (file, name) => {
261
+ const transformFile = (file, name, contentType) => {
262
262
  if (typeof file === 'string' && isReactNativeUri(file)) {
263
- return { uri: file, name };
263
+ return file;
264
264
  }
265
- const uri = URL.createObjectURL(file);
266
- const type = file.type;
267
- return { uri, name, type };
265
+ // const uri = URL.createObjectURL(file as BrowserFile)
266
+ // const type = contentType || (file as BrowserFile).type
267
+ return file;
268
268
  };
269
269
  var getFormData = () => new FormData();
270
270
 
@@ -312,7 +312,7 @@ const isFileValue = (value) => !!value &&
312
312
  function collectParams(params, inputKey, inputValue) {
313
313
  if (isFileValue(inputValue)) {
314
314
  const { name, contentType } = inputValue;
315
- const file = transformFile(inputValue.data, name); // lgtm [js/superfluous-trailing-arguments]
315
+ const file = transformFile(inputValue.data); // lgtm [js/superfluous-trailing-arguments]
316
316
  const options = getFileOptions({ name, contentType });
317
317
  params.push([inputKey, file, ...options]);
318
318
  }
@@ -468,7 +468,8 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
468
468
  jsonerrors: 1
469
469
  }),
470
470
  headers: {
471
- 'X-UC-User-Agent': getUserAgent({ publicKey, integration, userAgent })
471
+ 'X-UC-User-Agent': getUserAgent({ publicKey, integration, userAgent }),
472
+ 'content-type': 'multipart/form-data'
472
473
  },
473
474
  data: buildFormData({
474
475
  file: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "6.0.1-alpha.3",
3
+ "version": "6.0.1-alpha.5",
4
4
  "description": "Library for work with Uploadcare Upload API",
5
5
  "type": "module",
6
6
  "module": "./dist/index.node.js",