S3 Storage Return Additional Response



  • Hi,

    I recently increased version of jsreport from 1.7.0 to 2.3.0 on my server due to some security fixes available in latest version's.

    I used jsreport-s3-storage with some extra customization -

    1. For picking a path which I was sending in headers to upload reports to s3 and
    2. Return a response with the file path (s3 url) by which report could be downloaded example - https://xyz.com/reports/<app_name>/<report_name>

    I can see that there is an official aws s3 uploader available now, would like to know how to achieve above 2 points in this new module.

    Can we update response header in the function write: (defaultBlobName, buffer, request, response) ?

    If not what can I do to return an s3 file path where reports are getting stored ?

    Also, I ran official aws s3 uploader with config as told in guide. For some reason there is nothing happening in the code I placed a console.log in init function which is being called. But write function is not getting triggered.

    Am I doing something wrong ? Here is the output from my jsreport terminal -

    2019-01-04T08:17:03.731Z - debug: Base url not specified, skipping its injection.
    2019-01-04T08:17:03.731Z - debug: Rendering engine handlebars
    2019-01-04T08:17:04.007Z - debug: Compiled template not found in the cache, compiling
    2019-01-04T08:17:04.013Z - debug: Executing recipe xlsx
    2019-01-04T08:17:04.014Z - debug: Parsing xlsx content
    2019-01-04T08:17:04.044Z - debug: Zipping prepared xml files into /tmp/jsreport/autocleanup/1e4236c0-0ff9-11e9-85d6-67831e59f236.xlsx
    2019-01-04T08:17:04.091Z - debug: Successfully zipped now.
    2019-01-04T08:17:04.095Z - debug: Skipping storing report.
    2019-01-04T08:17:04.099Z - info: Rendering request 1 finished in 515 ms
    


  • The s3 storage extension is just about storing blobs.
    You need to use it together with reports extension if you want to save reports output and add file paths to the headers.
    See the docs
    https://jsreport.net/learn/reports



  • Hi Jan Blaha,

    Thanks for your quick reply.

    Code is now getting called and I am able to customize your code to store file in custom s3 folder.

    Added following "reports": { "save": true } to my options object.

    It might be helpful for others if you could mention it in module's readme file somewhere, to add "reports": { "save": true } in options.

    Thanks a lot!



  • Great.

    Yes, I updated docs to explain the blob storage and linked it from the storage repositories.
    https://jsreport.net/learn/blob-storages


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.