fix: cannot upload attachment files in docker (#241)

This commit is contained in:
kimatata
2025-07-12 16:48:56 +09:00
committed by GitHub
parent a42c3e3c5c
commit ed1e90c714
13 changed files with 50 additions and 33 deletions

View File

@@ -1,9 +1,9 @@
const fs = require('fs');
const path = require('path');
const express = require('express');
const router = express.Router();
const path = require('path');
const fs = require('fs');
const defineAttachment = require('../../models/attachments');
const { DataTypes } = require('sequelize');
const defineAttachment = require('../../models/attachments');
module.exports = function (sequelize) {
const Attachment = defineAttachment(sequelize, DataTypes);
@@ -21,9 +21,7 @@ module.exports = function (sequelize) {
// delete file from folder
const uploadDir = path.join(__dirname, '../../public/uploads');
const url = attachment.path;
const fileName = url.substring(url.lastIndexOf('/') + 1);
const filePath = path.join(uploadDir, fileName);
const filePath = path.join(uploadDir, attachment.filename);
fs.unlink(filePath, (err) => {
if (err) {
console.error('Error deleting file:', err);