rads-db 0.1.53 → 0.1.54
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.
|
@@ -40,7 +40,22 @@ async function getJsonBody(args) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
async function blobToDataUrl(blob) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (FileReader) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const a = new FileReader();
|
|
46
|
+
a.onload = function (e) {
|
|
47
|
+
resolve(e.target?.result);
|
|
48
|
+
};
|
|
49
|
+
a.onerror = function (e) {
|
|
50
|
+
reject(new Error(["Error parsing blob", e.target?.error].filter(x => x).join(": ")));
|
|
51
|
+
};
|
|
52
|
+
a.readAsDataURL(blob);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (Buffer) {
|
|
56
|
+
const buf = await blob.arrayBuffer();
|
|
57
|
+
const b64string = Buffer.from(buf).toString("base64");
|
|
58
|
+
return `data:${blob.type};base64,${b64string}`;
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`Cannot parse blob on this environment. Consider using formData instead.`);
|
|
46
61
|
}
|
|
@@ -30,7 +30,22 @@ async function getJsonBody(args) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
async function blobToDataUrl(blob) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (FileReader) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const a = new FileReader();
|
|
36
|
+
a.onload = function(e) {
|
|
37
|
+
resolve(e.target?.result);
|
|
38
|
+
};
|
|
39
|
+
a.onerror = function(e) {
|
|
40
|
+
reject(new Error(["Error parsing blob", e.target?.error].filter((x) => x).join(": ")));
|
|
41
|
+
};
|
|
42
|
+
a.readAsDataURL(blob);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (Buffer) {
|
|
46
|
+
const buf = await blob.arrayBuffer();
|
|
47
|
+
const b64string = Buffer.from(buf).toString("base64");
|
|
48
|
+
return `data:${blob.type};base64,${b64string}`;
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Cannot parse blob on this environment. Consider using formData instead.`);
|
|
36
51
|
}
|