feat: add dynamic site settings, hero media, admin panels, and database integration
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { v2 as cloudinary } from 'cloudinary';
|
||||
|
||||
export async function uploadImage(file: File): Promise<string> {
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const uploadStream = cloudinary.uploader.upload_stream(
|
||||
{ folder: 'moybeach', resource_type: 'auto' },
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(result!.secure_url);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
uploadStream.end(buffer);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user