Skip to content

Commit 952e64d

Browse files
stephentusoflovilmart
authored andcommitted
Update FilesAdapter comments (#4065)
1 parent 1914083 commit 952e64d

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

src/Adapters/Files/FilesAdapter.js

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,54 @@
44
// Allows you to change the file storage mechanism.
55
//
66
// 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)
1011
//
1112
// Default is GridStoreAdapter, which requires mongo
1213
// and for the API server to be using the DatabaseController with Mongo
1314
// database adapter.
1415

16+
import type { Config } from '../../Config'
17+
1518
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
1721
*
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
2125
* @discussion the contentType can be undefined if the controller was not able to determine it
2226
*
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
2528
*/
26-
createFile(filename: string, data, contentType: string) { }
29+
createFile(filename: string, data, contentType: string): Promise { }
2730

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 { }
2938

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> { }
3146

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 { }
3355
}
3456

3557
export default FilesAdapter;

0 commit comments

Comments
 (0)