|
4 | 4 | // Allows you to change the file storage mechanism.
|
5 | 5 | //
|
6 | 6 | // Adapter classes must implement the following functions:
|
7 |
| -// * createFile(config, filename, data) |
8 |
| -// * getFileData(config, filename) |
9 |
| -// * getFileLocation(config, request, filename) |
| 7 | +// * createFile(filename, data, contentType) |
| 8 | +// * deleteFile(filename) |
| 9 | +// * getFileData(filename) |
| 10 | +// * getFileLocation(config, filename) |
10 | 11 | //
|
11 | 12 | // Default is GridStoreAdapter, which requires mongo
|
12 | 13 | // and for the API server to be using the DatabaseController with Mongo
|
13 | 14 | // database adapter.
|
14 | 15 |
|
| 16 | +import type { Config } from '../../Config' |
| 17 | + |
15 | 18 | export class FilesAdapter {
|
16 |
| - /* This method is responsible to store the file in order to be retrieved later by its file name |
| 19 | + |
| 20 | + /* Responsible for storing the file in order to be retrieved later by its filename |
17 | 21 | *
|
18 |
| - * @param filename the filename to save |
19 |
| - * @param data the buffer of data from the file |
20 |
| - * @param contentType the supposed contentType |
| 22 | + * @param {string} filename - the filename to save |
| 23 | + * @param {*} data - the buffer of data from the file |
| 24 | + * @param {string} contentType - the supposed contentType |
21 | 25 | * @discussion the contentType can be undefined if the controller was not able to determine it
|
22 | 26 | *
|
23 |
| - * @return a promise that should fail if the storage didn't succeed |
24 |
| - * |
| 27 | + * @return {Promise} a promise that should fail if the storage didn't succeed |
25 | 28 | */
|
26 |
| - createFile(filename: string, data, contentType: string) { } |
| 29 | + createFile(filename: string, data, contentType: string): Promise { } |
27 | 30 |
|
28 |
| - deleteFile(filename) { } |
| 31 | + /* Responsible for deleting the specified file |
| 32 | + * |
| 33 | + * @param {string} filename - the filename to delete |
| 34 | + * |
| 35 | + * @return {Promise} a promise that should fail if the deletion didn't succeed |
| 36 | + */ |
| 37 | + deleteFile(filename: string): Promise { } |
29 | 38 |
|
30 |
| - getFileData(filename) { } |
| 39 | + /* Responsible for retrieving the data of the specified file |
| 40 | + * |
| 41 | + * @param {string} filename - the name of file to retrieve |
| 42 | + * |
| 43 | + * @return {Promise} a promise that should pass with the file data or fail on error |
| 44 | + */ |
| 45 | + getFileData(filename: string): Promise<any> { } |
31 | 46 |
|
32 |
| - getFileLocation(config, filename) { } |
| 47 | + /* Returns an absolute URL where the file can be accessed |
| 48 | + * |
| 49 | + * @param {Config} config - server configuration |
| 50 | + * @param {string} filename |
| 51 | + * |
| 52 | + * @return {string} Absolute URL |
| 53 | + */ |
| 54 | + getFileLocation(config: Config, filename: string): string { } |
33 | 55 | }
|
34 | 56 |
|
35 | 57 | export default FilesAdapter;
|
0 commit comments