Update FilesAdapter comments (#4065)

This commit is contained in:
Stephen Tuso
2017-09-09 13:11:16 -04:00
committed by Florent Vilmart
parent 1914083942
commit 952e64d94a

View File

@@ -4,32 +4,54 @@
// Allows you to change the file storage mechanism. // Allows you to change the file storage mechanism.
// //
// Adapter classes must implement the following functions: // Adapter classes must implement the following functions:
// * createFile(config, filename, data) // * createFile(filename, data, contentType)
// * getFileData(config, filename) // * deleteFile(filename)
// * getFileLocation(config, request, filename) // * getFileData(filename)
// * getFileLocation(config, filename)
// //
// Default is GridStoreAdapter, which requires mongo // Default is GridStoreAdapter, which requires mongo
// and for the API server to be using the DatabaseController with Mongo // and for the API server to be using the DatabaseController with Mongo
// database adapter. // database adapter.
import type { Config } from '../../Config'
export class FilesAdapter { export class FilesAdapter {
/* This method is responsible to store the file in order to be retrieved later by its file name
/* Responsible for storing the file in order to be retrieved later by its filename
* *
* @param filename the filename to save * @param {string} filename - the filename to save
* @param data the buffer of data from the file * @param {*} data - the buffer of data from the file
* @param contentType the supposed contentType * @param {string} contentType - the supposed contentType
* @discussion the contentType can be undefined if the controller was not able to determine it * @discussion the contentType can be undefined if the controller was not able to determine it
* *
* @return a promise that should fail if the storage didn't succeed * @return {Promise} a promise that should fail if the storage didn't succeed
*
*/ */
createFile(filename: string, data, contentType: string) { } createFile(filename: string, data, contentType: string): Promise { }
deleteFile(filename) { } /* Responsible for deleting the specified file
*
* @param {string} filename - the filename to delete
*
* @return {Promise} a promise that should fail if the deletion didn't succeed
*/
deleteFile(filename: string): Promise { }
getFileData(filename) { } /* Responsible for retrieving the data of the specified file
*
* @param {string} filename - the name of file to retrieve
*
* @return {Promise} a promise that should pass with the file data or fail on error
*/
getFileData(filename: string): Promise<any> { }
getFileLocation(config, filename) { } /* Returns an absolute URL where the file can be accessed
*
* @param {Config} config - server configuration
* @param {string} filename
*
* @return {string} Absolute URL
*/
getFileLocation(config: Config, filename: string): string { }
} }
export default FilesAdapter; export default FilesAdapter;