@uploadcare/upload-client 6.0.0 → 6.0.1-alpha.1
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/dist/index.browser.js
CHANGED
|
@@ -264,7 +264,8 @@ const isFileData = (data) => {
|
|
|
264
264
|
return (data !== undefined &&
|
|
265
265
|
((typeof Blob !== 'undefined' && data instanceof Blob) ||
|
|
266
266
|
(typeof File !== 'undefined' && data instanceof File) ||
|
|
267
|
-
(typeof Buffer !== 'undefined' && data instanceof Buffer)
|
|
267
|
+
(typeof Buffer !== 'undefined' && data instanceof Buffer) ||
|
|
268
|
+
(typeof data === 'string' && data.startsWith('file:'))));
|
|
268
269
|
};
|
|
269
270
|
/**
|
|
270
271
|
* Uuid type guard.
|
|
@@ -326,9 +327,9 @@ function buildFormData(options) {
|
|
|
326
327
|
const formData = getFormData();
|
|
327
328
|
const paramsList = getFormDataParams(options);
|
|
328
329
|
for (const params of paramsList) {
|
|
329
|
-
const [key, value, ...
|
|
330
|
+
const [key, value, ...rest] = params;
|
|
330
331
|
// node form-data has another signature for append
|
|
331
|
-
formData.append(key, value, ...
|
|
332
|
+
formData.append(key, value, ...rest);
|
|
332
333
|
}
|
|
333
334
|
return formData;
|
|
334
335
|
}
|
|
@@ -459,7 +460,7 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
459
460
|
data: buildFormData({
|
|
460
461
|
file: {
|
|
461
462
|
data: file,
|
|
462
|
-
name: fileName ?? file
|
|
463
|
+
name: fileName ?? file?.name ?? defaultFilename,
|
|
463
464
|
contentType
|
|
464
465
|
},
|
|
465
466
|
UPLOADCARE_PUB_KEY: publicKey,
|
package/dist/index.node.js
CHANGED
|
@@ -292,7 +292,8 @@ const isFileData = (data) => {
|
|
|
292
292
|
return (data !== undefined &&
|
|
293
293
|
((typeof Blob !== 'undefined' && data instanceof Blob) ||
|
|
294
294
|
(typeof File !== 'undefined' && data instanceof File) ||
|
|
295
|
-
(typeof Buffer !== 'undefined' && data instanceof Buffer)
|
|
295
|
+
(typeof Buffer !== 'undefined' && data instanceof Buffer) ||
|
|
296
|
+
(typeof data === 'string' && data.startsWith('file:'))));
|
|
296
297
|
};
|
|
297
298
|
/**
|
|
298
299
|
* Uuid type guard.
|
|
@@ -354,9 +355,9 @@ function buildFormData(options) {
|
|
|
354
355
|
const formData = getFormData();
|
|
355
356
|
const paramsList = getFormDataParams(options);
|
|
356
357
|
for (const params of paramsList) {
|
|
357
|
-
const [key, value, ...
|
|
358
|
+
const [key, value, ...rest] = params;
|
|
358
359
|
// node form-data has another signature for append
|
|
359
|
-
formData.append(key, value, ...
|
|
360
|
+
formData.append(key, value, ...rest);
|
|
360
361
|
}
|
|
361
362
|
return formData;
|
|
362
363
|
}
|
|
@@ -487,7 +488,7 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
487
488
|
data: buildFormData({
|
|
488
489
|
file: {
|
|
489
490
|
data: file,
|
|
490
|
-
name: fileName ?? file
|
|
491
|
+
name: fileName ?? file?.name ?? defaultFilename,
|
|
491
492
|
contentType
|
|
492
493
|
},
|
|
493
494
|
UPLOADCARE_PUB_KEY: publicKey,
|
|
@@ -251,8 +251,8 @@ const request = ({ method, url, data, headers = {}, signal, onProgress }) => new
|
|
|
251
251
|
|
|
252
252
|
const getFileOptions = ({ name }) => name ? [name] : [];
|
|
253
253
|
const transformFile = (file, name) => {
|
|
254
|
-
if (
|
|
255
|
-
return file;
|
|
254
|
+
if (typeof file === 'string' && file.startsWith('file:')) {
|
|
255
|
+
return { uri: file, name };
|
|
256
256
|
}
|
|
257
257
|
const uri = URL.createObjectURL(file);
|
|
258
258
|
const type = file.type;
|
|
@@ -267,7 +267,8 @@ const isFileData = (data) => {
|
|
|
267
267
|
return (data !== undefined &&
|
|
268
268
|
((typeof Blob !== 'undefined' && data instanceof Blob) ||
|
|
269
269
|
(typeof File !== 'undefined' && data instanceof File) ||
|
|
270
|
-
(typeof Buffer !== 'undefined' && data instanceof Buffer)
|
|
270
|
+
(typeof Buffer !== 'undefined' && data instanceof Buffer) ||
|
|
271
|
+
(typeof data === 'string' && data.startsWith('file:'))));
|
|
271
272
|
};
|
|
272
273
|
/**
|
|
273
274
|
* Uuid type guard.
|
|
@@ -329,9 +330,9 @@ function buildFormData(options) {
|
|
|
329
330
|
const formData = getFormData();
|
|
330
331
|
const paramsList = getFormDataParams(options);
|
|
331
332
|
for (const params of paramsList) {
|
|
332
|
-
const [key, value, ...
|
|
333
|
+
const [key, value, ...rest] = params;
|
|
333
334
|
// node form-data has another signature for append
|
|
334
|
-
formData.append(key, value, ...
|
|
335
|
+
formData.append(key, value, ...rest);
|
|
335
336
|
}
|
|
336
337
|
return formData;
|
|
337
338
|
}
|
|
@@ -462,7 +463,7 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
462
463
|
data: buildFormData({
|
|
463
464
|
file: {
|
|
464
465
|
data: file,
|
|
465
|
-
name: fileName ?? file
|
|
466
|
+
name: fileName ?? file?.name ?? defaultFilename,
|
|
466
467
|
contentType
|
|
467
468
|
},
|
|
468
469
|
UPLOADCARE_PUB_KEY: publicKey,
|