Skip to content

Commit

Permalink
Merge pull request #6 from PipeItToDevNull/4-download-files-as-a-spec…
Browse files Browse the repository at this point in the history
…ifc-name-naming-convention-to-avoid-issues

when getting a file name it after the time in milliseconds
  • Loading branch information
PipeItToDevNull authored Nov 3, 2024
2 parents 02d302c + 09e172e commit bccd201
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 bccd201

Please sign in to comment.