2021-01-05 16:12:38 -05:00
|
|
|
/*
|
2021-01-06 15:36:07 -05:00
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2021-01-05 16:12:38 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2020-10-16 16:29:13 -04:00
|
|
|
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.
|
2021-02-25 07:51:54 -05:00
|
|
|
* @throws {MediaBackendError} - there was an error saving the file
|
2020-10-16 16:29:13 -04:00
|
|
|
* @return Tuple of file URL and internal backend data, which should be saved.
|
|
|
|
*/
|
|
|
|
saveFile(buffer: Buffer, fileName: string): Promise<[string, BackendData]>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a file from the backend
|
|
|
|
* @param fileName String to identify the file
|
|
|
|
* @param backendData Internal backend data
|
2021-02-25 07:51:54 -05:00
|
|
|
* @throws {MediaBackendError} - there was an error retrieving the url
|
2020-10-16 16:29:13 -04:00
|
|
|
*/
|
|
|
|
deleteFile(fileName: string, backendData: BackendData): Promise<void>;
|
|
|
|
}
|