problem with res.download

Hi, in my application i need to download a file that is created inside a folder that is created at run-time, i can see from the prompt that the path is correct, but when the path is passed to res.download the folder is undefined, this isa my code:

console.log('folder',id)
var folder = id.toString()
              var file = [root,"/app/temp/",folder, "/registrazioni.zip"].join("")
              console.log('file',file)
              res.download(file,'registrazioni.zip')

this is the output of the server:

folder 1486999889561 
file /home/giuseppe/projects/csgSAW/app/temp/1486999889561/registrazioni.zip
path /home/giuseppe/projects/csgSAW/app/temp/undefined/registrazioni.zip
download done { [Error: ENOENT: no such file or directory, stat '/home/giuseppe/projects/csgSAW/app/temp/undefined/registrazioni.zip']
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/home/giuseppe/projects/csgSAW/app/temp/undefined/registrazioni.zip',
  expose: false,
  statusCode: 404,
  status: 404 }

I am puzzled, it is like something changes the string after is passed to res.download;
thanks in advance

Author: Fantashit

1 thought on “problem with res.download

Comments are closed.