@ahhaohho/s3-upload-sdk
Version:
S3 + CloudFront presigned URL SDK for AhhaOhho platform
89 lines (88 loc) • 1.68 kB
TypeScript
/**
* Configuration for S3 Upload SDK
*/
export interface S3UploadConfig {
/**
* Base URL of your API server that generates presigned URLs
*/
apiBaseUrl: string;
/**
* Optional authorization token for API requests
*/
authToken?: string;
/**
* Custom headers to send with API requests
*/
headers?: Record<string, string>;
}
/**
* Presigned URL response from API
*/
export interface PresignedUrlResponse {
/**
* Presigned URL for uploading to S3
*/
uploadUrl: string;
/**
* Final CloudFront URL where the file will be accessible
*/
publicUrl: string;
/**
* S3 key (file path)
*/
key: string;
/**
* Expiration time of the presigned URL
*/
expiresIn?: number;
}
/**
* Upload options
*/
export interface UploadOptions {
/**
* File to upload
*/
file: File | Blob;
/**
* Folder path in S3 (e.g., 'announcements', 'profiles')
*/
folder: string;
/**
* Optional custom filename (without extension)
*/
filename?: string;
/**
* Content type (MIME type)
*/
contentType?: string;
/**
* Progress callback
*/
onProgress?: (progress: number) => void;
}
/**
* Upload result
*/
export interface UploadResult {
/**
* Final CloudFront URL where the file is accessible
*/
url: string;
/**
* S3 key (file path)
*/
key: string;
/**
* File size in bytes
*/
size: number;
}
/**
* Error response from API or S3
*/
export interface UploadError extends Error {
code?: string;
statusCode?: number;
details?: any;
}