2019-06-20 05:46:30 +00:00
|
|
|
const uuid = require('uuid/v1');
|
|
|
|
const md5 = require('md5');
|
|
|
|
|
|
|
|
module.exports = app => {
|
|
|
|
const storageConnector = app.dataSources.storage.connector;
|
|
|
|
|
|
|
|
storageConnector.getFilename = function(file) {
|
|
|
|
return `${uuid()}.${storageConnector.getFileExtension(file.name)}`;
|
|
|
|
};
|
|
|
|
|
|
|
|
storageConnector.getFileExtension = function(fileName) {
|
|
|
|
return fileName.split('.').pop();
|
|
|
|
};
|
|
|
|
|
|
|
|
storageConnector.getPathHash = function(id) {
|
2019-06-20 09:25:04 +00:00
|
|
|
return md5(id).substring(0, 3);
|
2019-06-20 05:46:30 +00:00
|
|
|
};
|
|
|
|
};
|