mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-02-09 11:05:25 -06:00
24 lines
634 B
JavaScript
24 lines
634 B
JavaScript
export const formatBytes = (bytes) => {
|
|
if (bytes === 0) return "0 Bytes";
|
|
const megabytes = bytes / (1024 * 1024);
|
|
return megabytes.toFixed(2) + " MB";
|
|
};
|
|
|
|
export const checkImage = (url) => {
|
|
const img = new Image();
|
|
img.src = url;
|
|
return img.naturalWidth !== 0;
|
|
};
|
|
|
|
export const bufferTo64 = (bufferData) => {
|
|
const uint8Array = new Uint8Array(bufferData.data);
|
|
const blob = new Blob([uint8Array], { type: bufferData.contentType });
|
|
return new Promise((resolve) => {
|
|
const reader = new FileReader();
|
|
reader.onloadend = () => {
|
|
resolve(reader.result);
|
|
};
|
|
reader.readAsDataURL(blob);
|
|
});
|
|
};
|