19 lines
511 B
JavaScript
19 lines
511 B
JavaScript
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) {
|
|
return md5(id.toString()).substring(0, 3);
|
|
};
|
|
};
|