filePathTool.js 576 B

1234567891011121314151617181920
  1. const config_path = require("../../configs/path.json");
  2. const dbField = require("../map/dbField");
  3. const {toNumber} = require("./typeTool_cjs");
  4. function filePathToUrl(fileType, fileName){
  5. let basePath = config_path.baseFiles;
  6. fileType = toNumber(fileType);
  7. if(fileType === dbField.db_base.fileType.image){
  8. basePath = config_path.baseImages;
  9. }else if(fileType === dbField.db_base.fileType.video){
  10. basePath = config_path.baseVideos;
  11. }else{
  12. basePath = config_path.baseFiles;
  13. }
  14. return `${basePath}/${fileName}`;
  15. }
  16. module.exports = {
  17. filePathToUrl
  18. }