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-07-11 06:17:32 +00:00
|
|
|
return md5(id.toString()).substring(0, 3);
|
2019-06-20 05:46:30 +00:00
|
|
|
};
|
|
|
|
};
|