copy storage function

This commit is contained in:
Philipinho
2025-04-27 15:34:43 +01:00
parent ed30f69023
commit 0296d97d72
3 changed files with 29 additions and 0 deletions

View File

@ -25,6 +25,16 @@ export class LocalDriver implements StorageDriver {
}
}
async copy(fromFilePath: string, toFilePath: string): Promise<void> {
try {
if (await this.exists(fromFilePath)) {
await fs.copy(fromFilePath, toFilePath);
}
} catch (err) {
throw new Error(`Failed to copy file: ${(err as Error).message}`);
}
}
async read(filePath: string): Promise<Buffer> {
try {
return await fs.readFile(this._fullPath(filePath));