Define a MediaBackend interface

This interface defines the functionality that all media backends (like S3 or Azure) must implement.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-10-16 22:29:13 +02:00
parent f01c7dbbe2
commit 9d8086bf3e
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -0,0 +1,25 @@
import { BackendData } from './media-upload.entity';
export interface MediaBackend {
/**
* Saves a file according to backend internals.
* @param buffer File data
* @param fileName Name of the file to save. Can include a file extension.
* @return Tuple of file URL and internal backend data, which should be saved.
*/
saveFile(buffer: Buffer, fileName: string): Promise<[string, BackendData]>;
/**
* Retrieve the URL of a previously saved file.
* @param fileName String to identify the file
* @param backendData Internal backend data
*/
getFileURL(fileName: string, backendData: BackendData): Promise<string>;
/**
* Delete a file from the backend
* @param fileName String to identify the file
* @param backendData Internal backend data
*/
deleteFile(fileName: string, backendData: BackendData): Promise<void>;
}