Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when getting a file name it after the time in milliseconds #6

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading