Deploy to production
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { api } from './api';
|
||||
|
||||
export const uploadAssetToStorage = async (file: Blob | File, bucket: string, path: string): Promise<string> => {
|
||||
try {
|
||||
const url = await api.uploadAsset(file);
|
||||
return url;
|
||||
} catch (err) {
|
||||
console.warn("Storage upload exception, falling back to data URL.", err);
|
||||
return await fileToDataUrl(file);
|
||||
}
|
||||
};
|
||||
|
||||
export const fileToDataUrl = (file: Blob | File): Promise<string> => {
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => resolve(reader.result as string);
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user