Skip to content

Commit

Permalink
when getting a file name it after the time in milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
PipeItToDevNull committed Nov 3, 2024
1 parent 02d302c commit 09e172e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,16 @@ const analyzeFile = (filePath, res) => {

// PUT and POST endpoint to receive .dmp file or URL and analyze it
const handleAnalyzeDmp = async (req, res) => {
if (req.file) {
// If a file is uploaded
const filePath = path.join(uploadsDir, req.file.originalname);
const currentTime = new Date().toISOString().slice(11, 23).replace(/[:.]/g, ''); // Get current time in HHMMSSmmm format

if (req.file) { // If a file is uploaded
const filePath = path.join(uploadsDir, `${currentTime}.dmp`);
logger.info(`File uploaded: ${filePath}`);
analyzeFile(filePath, res);
} else if (req.query.url) {
// If a URL is provided
} else if (req.query.url) { // If a URL is provided
const encodedUrl = req.query.url;
const url = decodeURIComponent(encodedUrl); // Decode the URL
const fileName = path.basename(url);
const filePath = path.join(uploadsDir, fileName);
const filePath = path.join(uploadsDir, `${currentTime}.dmp`);

try {
logger.info(`Fetching file from URL: ${url}`);
Expand Down

0 comments on commit 09e172e

Please sign in to comment.