jsreport / jsreport-wkhtmltopdf

jsreport recipe for rendering pdf using wkhtmltopdf
http://jsreport.net
MIT License
8 stars 9 forks source link

Return generated file name #2

Open Orvisky opened 8 years ago

Orvisky commented 8 years ago

Hi,

pls can you make small modification, that will return auto-generated file name? Because it is impossible to delete generated files, because names are automatically generated and hash is not returned.

    response.export = {
        fileName: 'f9dbc8a0-c50f-11e5-8c4c-23b94b1c16ce'
    }; 

      response.headers["Content-Type"] = "application/pdf";
      response.headers["Content-Disposition"] = "inline; filename=\"report.pdf\"";
      response.headers["File-Extension"] = "pdf";
f9dbc8a0-c50f-11e5-8c4c-23b94b1c16ce.pdf
f9dbc8a0-c50f-11e5-8c4c-23b94b1c16ce.html
f9dbc8a0-c50f-11e5-8c4c-23b94b1c16cefooter.html
f9dbc8a0-c50f-11e5-8c4c-23b94b1c16ceheader.html

Thank you

pofider commented 8 years ago

And why do you need this? These files are generated inside dedicated folder and the reaper module is taking care of removing the old ones. This is all provided through jsreport-core by default.

Orvisky commented 8 years ago

I need this, because we have strict temp file policy by sys admins. And i have to remove files, right after they are in res buffer.

I figure that it is simple, you just have to add this:

response.export = {
    fileName: id
}; 
pofider commented 8 years ago

This policy applies just to the OS temp folder right? You can change the jsreport tempDirectory configuration to the folder where you have no policies and you should be fine right?

Orvisky commented 8 years ago

No, node.js server is installed in classic server farm outside the company. We have limited space, and memories etc. on this exports. And policy is, when i create some tmp files, and download them, i have to remove them from servers manually in codes.

So when i download pdf from stream, i have to remove them manually, ex. via fs.unlinkSync(...). That is why i need that id returned.