@verdocs/js-sdk 1.1.15 → 1.1.16
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/Utils/Files.d.ts +5 -0
- package/Utils/Files.js +25 -0
- package/Utils/index.d.ts +1 -0
- package/Utils/index.js +1 -0
- package/package.json +1 -1
package/Utils/Files.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a File, extract the file's content as a base64 encoded data URL. The response will have a prefix that
|
|
3
|
+
* includes the MIME type of the file, e.g. "data:image/jpeg;base64,iVBORw0K......"
|
|
4
|
+
*/
|
|
5
|
+
export declare const fileToDataUrl: (file: File) => Promise<unknown>;
|
package/Utils/Files.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a File, extract the file's content as a base64 encoded data URL. The response will have a prefix that
|
|
3
|
+
* includes the MIME type of the file, e.g. "data:image/jpeg;base64,iVBORw0K......"
|
|
4
|
+
*/
|
|
5
|
+
export var fileToDataUrl = function (file) {
|
|
6
|
+
return new Promise(function (resolve, reject) {
|
|
7
|
+
var reader = new FileReader();
|
|
8
|
+
reader.onload = function () {
|
|
9
|
+
return resolve({
|
|
10
|
+
lastModified: file.lastModified,
|
|
11
|
+
size: file.size,
|
|
12
|
+
type: file.type,
|
|
13
|
+
name: file.name,
|
|
14
|
+
data: reader.result,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
reader.onerror = reject;
|
|
18
|
+
if (file) {
|
|
19
|
+
reader.readAsDataURL(file);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
reject(new Error('Invalid file'));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
package/Utils/index.d.ts
CHANGED
package/Utils/index.js
CHANGED