@uploadcare/upload-client 6.0.1-alpha.7 → 6.0.1-alpha.8
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 +7 -3
- package/dist/index.node.js +7 -3
- package/dist/index.react-native.js +14 -7
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -262,11 +262,15 @@ const transformFile = identity;
|
|
|
262
262
|
var getFormData = () => new FormData();
|
|
263
263
|
|
|
264
264
|
const isReactNativeUri = (uri) => {
|
|
265
|
+
if (typeof uri !== 'string') {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
265
268
|
return uri.startsWith('file:') || uri.startsWith('content:');
|
|
266
269
|
};
|
|
267
270
|
const isReactNativeAsset = (asset) => {
|
|
268
|
-
return (
|
|
269
|
-
|
|
271
|
+
return (!!asset &&
|
|
272
|
+
typeof asset === 'object' &&
|
|
273
|
+
!Array.isArray(asset) &&
|
|
270
274
|
'uri' in asset &&
|
|
271
275
|
typeof asset.uri === 'string' &&
|
|
272
276
|
isReactNativeUri(asset.uri));
|
|
@@ -479,7 +483,7 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
479
483
|
file: {
|
|
480
484
|
data: file,
|
|
481
485
|
name: fileName ?? file?.name ?? defaultFilename,
|
|
482
|
-
contentType
|
|
486
|
+
contentType: contentType ?? file?.type ?? defaultContentType
|
|
483
487
|
},
|
|
484
488
|
UPLOADCARE_PUB_KEY: publicKey,
|
|
485
489
|
UPLOADCARE_STORE: getStoreValue(store),
|
package/dist/index.node.js
CHANGED
|
@@ -286,11 +286,15 @@ const transformFile = identity;
|
|
|
286
286
|
var getFormData = () => new NodeFormData();
|
|
287
287
|
|
|
288
288
|
const isReactNativeUri = (uri) => {
|
|
289
|
+
if (typeof uri !== 'string') {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
289
292
|
return uri.startsWith('file:') || uri.startsWith('content:');
|
|
290
293
|
};
|
|
291
294
|
const isReactNativeAsset = (asset) => {
|
|
292
|
-
return (
|
|
293
|
-
|
|
295
|
+
return (!!asset &&
|
|
296
|
+
typeof asset === 'object' &&
|
|
297
|
+
!Array.isArray(asset) &&
|
|
294
298
|
'uri' in asset &&
|
|
295
299
|
typeof asset.uri === 'string' &&
|
|
296
300
|
isReactNativeUri(asset.uri));
|
|
@@ -503,7 +507,7 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
503
507
|
file: {
|
|
504
508
|
data: file,
|
|
505
509
|
name: fileName ?? file?.name ?? defaultFilename,
|
|
506
|
-
contentType
|
|
510
|
+
contentType: contentType ?? file?.type ?? defaultContentType
|
|
507
511
|
},
|
|
508
512
|
UPLOADCARE_PUB_KEY: publicKey,
|
|
509
513
|
UPLOADCARE_STORE: getStoreValue(store),
|
|
@@ -254,11 +254,15 @@ const request = ({ method, url, data, headers = {}, signal, onProgress }) => new
|
|
|
254
254
|
});
|
|
255
255
|
|
|
256
256
|
const isReactNativeUri = (uri) => {
|
|
257
|
+
if (typeof uri !== 'string') {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
257
260
|
return uri.startsWith('file:') || uri.startsWith('content:');
|
|
258
261
|
};
|
|
259
262
|
const isReactNativeAsset = (asset) => {
|
|
260
|
-
return (
|
|
261
|
-
|
|
263
|
+
return (!!asset &&
|
|
264
|
+
typeof asset === 'object' &&
|
|
265
|
+
!Array.isArray(asset) &&
|
|
262
266
|
'uri' in asset &&
|
|
263
267
|
typeof asset.uri === 'string' &&
|
|
264
268
|
isReactNativeUri(asset.uri));
|
|
@@ -266,15 +270,18 @@ const isReactNativeAsset = (asset) => {
|
|
|
266
270
|
|
|
267
271
|
const getFileOptions = ({ name }) => name ? [name] : [];
|
|
268
272
|
const transformFile = (file, name, contentType) => {
|
|
269
|
-
if (
|
|
273
|
+
if (isReactNativeUri(file)) {
|
|
270
274
|
return { uri: file, name, type: contentType };
|
|
271
275
|
}
|
|
272
276
|
if (isReactNativeAsset(file)) {
|
|
273
|
-
return
|
|
277
|
+
return {
|
|
278
|
+
uri: file.uri,
|
|
279
|
+
name: file.name || name,
|
|
280
|
+
type: file.type || contentType
|
|
281
|
+
};
|
|
274
282
|
}
|
|
275
283
|
const uri = URL.createObjectURL(file);
|
|
276
|
-
|
|
277
|
-
return { uri, name, type };
|
|
284
|
+
return { uri, name, type: contentType };
|
|
278
285
|
};
|
|
279
286
|
var getFormData = () => new FormData();
|
|
280
287
|
|
|
@@ -485,7 +492,7 @@ function base(file, { publicKey, fileName, contentType, baseURL = defaultSetting
|
|
|
485
492
|
file: {
|
|
486
493
|
data: file,
|
|
487
494
|
name: fileName ?? file?.name ?? defaultFilename,
|
|
488
|
-
contentType
|
|
495
|
+
contentType: contentType ?? file?.type ?? defaultContentType
|
|
489
496
|
},
|
|
490
497
|
UPLOADCARE_PUB_KEY: publicKey,
|
|
491
498
|
UPLOADCARE_STORE: getStoreValue(store),
|