@qlibs/utils 1.7.2 → 1.7.3
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/utils/image.d.ts +1 -1
- package/dist/utils/image.js +14 -6
- package/package.json +1 -1
package/dist/utils/image.d.ts
CHANGED
@@ -8,5 +8,5 @@ export declare function bytesToMB(sizeInBytes: number): number;
|
|
8
8
|
export declare function isImage(file: File | Blob): any;
|
9
9
|
export declare const getBase64: (file: File) => Promise<string>;
|
10
10
|
export declare function fileListToBase64(fileList: any[]): Promise<string[]>;
|
11
|
-
export declare function getFile(newFile: File | any): any;
|
11
|
+
export declare function getFile(newFile: File | any, fileType?: 'image' | 'file'): any;
|
12
12
|
export declare function isPhotoDataOK(item: any): boolean;
|
package/dist/utils/image.js
CHANGED
@@ -105,14 +105,22 @@ async function fileListToBase64(fileList) {
|
|
105
105
|
}
|
106
106
|
return (await Promise.all(promises));
|
107
107
|
}
|
108
|
-
function getFile(newFile) {
|
109
|
-
console.info('getFile - newFile instanceof File', newFile instanceof File);
|
110
|
-
if (isImage(newFile) && newFile.originFileObj) {
|
111
|
-
console.info('getFile - return (newFile as any).originFileObj');
|
108
|
+
function getFile(newFile, fileType = 'image') {
|
109
|
+
console.info('getFile - newFile instanceof File', newFile instanceof File, fileType);
|
110
|
+
if (fileType === 'image' && isImage(newFile) && newFile.originFileObj) {
|
111
|
+
console.info('image - getFile - return (newFile as any).originFileObj');
|
112
112
|
return newFile.originFileObj;
|
113
113
|
}
|
114
|
-
else if (isImage(newFile) && newFile instanceof File) {
|
115
|
-
console.info('getFile - return newFile');
|
114
|
+
else if (fileType === 'image' && isImage(newFile) && newFile instanceof File) {
|
115
|
+
console.info('image - getFile - return newFile');
|
116
|
+
return newFile;
|
117
|
+
}
|
118
|
+
else if (fileType === 'file' && newFile.originFileObj) {
|
119
|
+
console.info('file - getFile - return (newFile as any).originFileObj');
|
120
|
+
return newFile.originFileObj;
|
121
|
+
}
|
122
|
+
else if (fileType === 'file' && newFile instanceof File) {
|
123
|
+
console.info('file - getFile - return newFile');
|
116
124
|
return newFile;
|
117
125
|
}
|
118
126
|
else {
|