routing-controllers
routing-controllers copied to clipboard
response.sendFile() return notfound error
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)
I think you might need to pass absolute path here: {root:'sftp-files/'}