///
export type FileData = {
fileId?: string;
content: Buffer;
contentType: string;
fileName: string;
folderPath: string;
storageFilePath?: string;
storageBucket?: string;
metadata?: Record;
};
export type FileDownloadUrl = {
downloadUrl: string;
contentType: string;
fileName: string;
};
export type FileReference = {
fileId: string;
reference: string;
providerId: string;
};
export interface IFileManager {
uploadFile(file: FileData): Promise;
removeFile(fileId: string): Promise;
getFileContent(fileId: string): Promise;
getFileDownloadUrl(fileId: string): Promise;
}
export type FilesReferenceData = {
reference: string;
providerId: string;
metadata?: Record;
fileId?: string;
fileName: string;
filePath: string;
fileSize: number;
contentType: string;
};
export type FileReferenceRecord = FilesReferenceData & {
fileId: string;
createdOn: Date;
updatedOn: Date;
};
export interface IFilesReferenceRepository {
searchReference({ reference, providerId, }: {
reference: string;
providerId: string;
}): Promise;
getReference(fileId: string): Promise;
createReference(file: FilesReferenceData): Promise;
updateReference(fileId: string, file: FilesReferenceData): Promise;
deleteReference(fileId: string): Promise;
}
export type FileProviderReference = {
reference: string;
bucket?: string;
};
export type FileProviderUploadData = {
fileId?: string;
fileName: string;
filePath?: string;
content: Buffer;
contentType: string;
bucket?: string;
};
export type FileProviderDownloadData = {
content: Buffer;
};
export type FileProviderDownloadUrl = {
downloadUrl: string;
};
export interface IFileProvider {
getProviderId(): string;
uploadFile(file: FileProviderUploadData): Promise;
deleteFile(reference: FileProviderReference): Promise;
downloadFile(reference: FileProviderReference): Promise;
getFileProviderDownloadUrl(reference: FileProviderReference): Promise;
get defaultBucket(): string;
}