routing-controllers icon indicating copy to clipboard operation
routing-controllers copied to clipboard

response.sendFile() return notfound error

Open PerumalsamyRajaveni opened this issue 3 years ago • 1 comments

I was trying to download files from client but routing-controller return NotFound error but my target file available in the mentioned path

Some one help to what's my mistakes

Code

import "reflect-metadata"; import { Body, Controller, Get, Param, Post, Req, Res } from "routing-controllers"; import { Response } from "express"; @Get('/dowloadfile') downloadfile( @Res() response: Response) { return response.sendFile('List.pdf',{root:'sftp-files/'}); } The problem:

Error: at NotFoundError.HttpError [as constructor] (D:\WorkSpace-PerumalSamy\abc\src\http-error\HttpError.ts:19:22) at new NotFoundError (D:\WorkSpace-PerumalSamy\abc\src\http-error\NotFoundError.ts:10:9) at ExpressDriver.handleSuccess (D:\WorkSpace-PerumalSamy\abc\src\driver\express\ExpressDriver.ts:332:23) at D:\WorkSpace-PerumalSamy\abc\src\RoutingControllers.ts:160:45 at processTicksAndRejections (internal/process/task_queues.js:97:5)

PerumalsamyRajaveni avatar Nov 10 '20 09:11 PerumalsamyRajaveni

I think you might need to pass absolute path here: {root:'sftp-files/'}

vs4vijay avatar Nov 22 '20 16:11 vs4vijay