Files
kami-parse-server/src/Adapters/Files/FilesAdapter.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

/*eslint no-unused-vars: "off"*/
2016-01-28 10:58:12 -08:00
// Files Adapter
//
// Allows you to change the file storage mechanism.
//
// Adapter classes must implement the following functions:
2017-09-09 13:11:16 -04:00
// * createFile(filename, data, contentType)
// * deleteFile(filename)
// * getFileData(filename)
// * getFileLocation(config, filename)
2016-01-28 10:58:12 -08:00
//
// Default is GridStoreAdapter, which requires mongo
// and for the API server to be using the DatabaseController with Mongo
2016-01-28 10:58:12 -08:00
// database adapter.
2017-09-09 13:11:16 -04:00
import type { Config } from '../../Config'
2016-02-08 22:51:58 -08:00
export class FilesAdapter {
2017-09-09 13:11:16 -04:00
/* Responsible for storing the file in order to be retrieved later by its filename
*
2017-09-09 13:11:16 -04:00
* @param {string} filename - the filename to save
* @param {*} data - the buffer of data from the file
* @param {string} contentType - the supposed contentType
* @discussion the contentType can be undefined if the controller was not able to determine it
*
2017-09-09 13:11:16 -04:00
* @return {Promise} a promise that should fail if the storage didn't succeed
2016-03-01 15:45:11 -05:00
*/
2017-09-09 13:11:16 -04:00
createFile(filename: string, data, contentType: string): Promise { }
2016-02-08 22:51:58 -08:00
2017-09-09 13:11:16 -04:00
/* 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 { }
2016-02-10 18:42:21 -05:00
2017-09-09 13:11:16 -04:00
/* 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> { }
2016-02-08 22:51:58 -08:00
2017-09-09 13:11:16 -04:00
/* 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 { }
2016-02-08 22:51:58 -08:00
}
export default FilesAdapter;