Back End Development and APIs Projects - File Metadata Microservice

Tell us what’s happening:

Test case 4 is not passing even if my solution is correct.Please check bugs on your side

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

Challenge Information:

Back End Development and APIs Projects - File Metadata Microservice

Welcome to the forum @

Please post your full code.

Happy coding

var express = require('express');

var cors = require('cors');

var multer = require('multer');

require('dotenv').config();



var app = express();

var storage = multer.memoryStorage();

var upload = multer({ 'storage': storage })



app.use(cors());

app.use('/public', express.static(process.cwd() + '/public'));



app.get('/', function (req, res) {

    console.log("=====================\\nHomepage called\\n=====================");

    res.sendFile(process.cwd() + '/views/index.html');

});



app.post('/api/fileanalyse', upload.single('upfile'), (req, res) => {

    console.log("=====================\\nAnalysis called\\n=====================");

    if (!req.file) {

        return res.status(400).json({ 'message': 'No file uploaded'})

    }

    res.json({

        'name': req.file.originalname,

        'type': req.file.mimetype,

        'size': req.file.size

    });

});



const port = process.env.PORT || 3000;

app.listen(port, function () {

    console.log('Your app is listening on port ' + port)

});

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').