generated from agiledev-students-fall2023/generic-project-repository
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
also implemented file removal from create request
- Loading branch information
1 parent
b73ccab
commit cff64fe
Showing
2 changed files
with
25 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
import multer from 'multer'; | ||
import { createIssueHandler } from '../controllers/createIssueHandler.js'; | ||
import express from 'express'; | ||
import multer from "multer"; | ||
import { createIssueHandler } from "../controllers/createIssueHandler.js"; | ||
import express from "express"; | ||
|
||
const router = express.Router(); | ||
|
||
const storage = multer.diskStorage({ | ||
destination: function(req, file, cb) { | ||
cb(null, 'uploads/'); | ||
}, | ||
filename: function (req, file, cb) { | ||
cb(null, file.originalname); | ||
} | ||
}); | ||
const upload = multer({ storage: storage }); | ||
destination: function (req, file, cb) { | ||
cb(null, "uploads/"); | ||
}, | ||
filename: function (req, file, cb) { | ||
// Get the current time | ||
const currentTime = new Date().toISOString().replace(/:/g, "-"); | ||
// Append the current time to the original filename | ||
cb(null, currentTime + "-" + file.originalname); | ||
} | ||
}); | ||
const upload = multer({ storage }); | ||
|
||
router.post('/:studentNetID', upload.array('uploadedFiles'), createIssueHandler); | ||
router.post( | ||
"/:studentNetID", | ||
upload.array("uploadedFiles"), | ||
createIssueHandler | ||
); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters