feat: Add About Us page CMS functionality with dedicated sections and image upload support.
This commit is contained in:
@@ -1,8 +1,36 @@
|
||||
import api from './api';
|
||||
|
||||
interface PresignedUrlResponse {
|
||||
uploadUrl: string;
|
||||
publicUrl: string;
|
||||
key: string;
|
||||
}
|
||||
|
||||
class UploadService {
|
||||
private basePath = '/upload';
|
||||
|
||||
/**
|
||||
* Get a presigned upload URL for S3
|
||||
*/
|
||||
async getPresignedUploadUrl(filename: string, contentType: string, folder: string): Promise<PresignedUrlResponse> {
|
||||
const response = await api.post<{ data: PresignedUrlResponse }>(
|
||||
`${this.basePath}/presigned-url`,
|
||||
{ filename, contentType, folder }
|
||||
);
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file to S3 using a presigned URL
|
||||
*/
|
||||
async uploadFileToS3(uploadUrl: string, file: File): Promise<void> {
|
||||
await fetch(uploadUrl, {
|
||||
method: 'PUT',
|
||||
body: file,
|
||||
headers: { 'Content-Type': file.type },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a presigned download URL for an S3 key
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user