Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Get filename from route

I have route like /gcp/filename

import downloadGCP from './controllers/downloadGCP';
router.route('/gcp')
    .get(downloadGCP);

inside ./controllers/downloadGCP.js, how should I get the filename? Below is code for downloadGCP.js

export default async (req, res) => {
//<--To get filename
}
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

The route /gcp will not match GET /gcp/filename request. I think the route should be /gcp/:filename (filename is a "variable" name).

Now, you can get filename value by req.params.filename.

about 4 years ago · Santiago Gelvez Report

0

To get filename you need to first configure your router like this

import downloadGCP from './controllers/downloadGCP';
router.route('/gcp/:filename').get(downloadGCP);

and inside downloadGCP to get the file you need to get the file from request, like so:

export default async (req, res) => {
  const file = req.params.file 

  ...other stuff...
}

or depending on how you have structured and send your request

 export default async (req, res) => {
      const file = req.body.file // or req.file
    
      ...other stuff...
    }
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!