jsreport-aws-s3-storage using environment variables



  • Hi,

    I am trying to upload the phantom-pdf rendered to an S3 bucket using the jsreport-aws-s3-storage extension with the details defined by environment variables. I have the following in my config file as described in documentation:

       {
          "template": { "shortid" : "g1PyBkARK" },
          "data" : { ... },
          "options": {
              "reports": { "save": true }
          }
       }
    

    In my .js file, I have

        var jsreport_core = require('jsreport-core') ({ blobStorage: { provider: 'aws-s3-storage' } });
        jsreport_core.use(require('jsreport-aws-s3-storage')({
                "accessKeyId":  process.env.S3_SECRET_ACCESS_KEY,
    			"secretAccessKey":  process.env.S3_ACCESS_KEY_ID,
    			"bucket": process.env.S3_BUCKET_NAME,
    			"s3Options": {}
        }));
    

    The variables are passing in fine, but the file is not being uploaded into the S3 bucket. Any tips?


  • administrators

    hi! can you share the logs generated at startup and also the logs when you render the template? make sure to start jsreport with env var DEBUG=jsreport* for better logs.



  • This post is deleted!


  • Hi there,

    Here are the logs:

    2019-03-24T19:50:00.159Z - info: Initializing jsreport@2.4.0 in development mode using configuration file: jsreport.config.json
    2019-03-24T19:50:00.164Z - info: Searching for available extensions in /app/
    2019-03-24T19:50:00.186Z - info: Extensions location cache contains up to date information, skipping crawling in /app/
    2019-03-24T19:50:02.493Z - info: Found 33 extensions
    2019-03-24T19:50:02.611Z - debug: Writing extension locations cache to /tmp/jsreport/core/locations.json
    2019-03-24T19:50:02.612Z - debug: Discovered 33 extensions
    2019-03-24T19:50:02.909Z - info: Using extension import-export
    2019-03-24T19:50:03.872Z - info: Using extension tags
    2019-03-24T19:50:03.883Z - info: Using extension aws-s3-storage
    2019-03-24T19:50:05.130Z - debug: Extension aws-s3-storage was disabled
    2019-03-24T19:50:05.131Z - info: Using extension templates
    2019-03-24T19:50:05.141Z - info: Using extension jsrender
    2019-03-24T19:50:05.147Z - debug: Extension authentication is disabled, skipping
    2019-03-24T19:50:05.147Z - info: Using extension handlebars
    2019-03-24T19:50:05.159Z - info: Using extension cli
    2019-03-24T19:50:05.164Z - info: Using extension freeze
    2019-03-24T19:50:05.169Z - info: Using extension debug
    2019-03-24T19:50:05.175Z - info: Using extension express
    2019-03-24T19:50:06.103Z - info: Using extension phantom-pdf
    2019-03-24T19:50:06.216Z - info: Using extension data
    2019-03-24T19:50:06.222Z - info: Using extension chrome-pdf
    2019-03-24T19:50:06.648Z - debug: Chrome strategy is dedicated-process
    2019-03-24T19:50:06.649Z - info: Using extension child-templates
    2019-03-24T19:50:06.673Z - info: Using extension browser-client
    2019-03-24T19:50:06.686Z - info: Using extension licensing
    2019-03-24T19:50:06.701Z - info: Using extension pdf-utils
    2019-03-24T19:50:07.096Z - info: Using extension authorization
    2019-03-24T19:50:07.113Z - debug: Extension authorization was disabled
    2019-03-24T19:50:07.113Z - info: Using extension version-control
    2019-03-24T19:50:07.598Z - info: Using extension reports
    2019-03-24T19:50:07.616Z - info: Using extension text
    2019-03-24T19:50:07.622Z - info: Using extension base
    2019-03-24T19:50:07.627Z - info: Using extension studio
    2019-03-24T19:50:07.727Z - debug: studio request logs are enabled (flush interval: 2000)
    2019-03-24T19:50:07.727Z - info: Using extension fs-store
    2019-03-24T19:50:09.372Z - info: Using extension scheduling
    2019-03-24T19:50:09.526Z - info: Using extension scripts
    2019-03-24T19:50:09.548Z - info: Using extension html-to-xlsx
    2019-03-24T19:50:10.141Z - info: html-to-xlsx detected chrome as available html engine
    2019-03-24T19:50:10.143Z - info: html-to-xlsx detected phantom as available html engine
    2019-03-24T19:50:10.144Z - info: Using extension assets
    2019-03-24T19:50:10.196Z - info: Using extension xlsx
    2019-03-24T19:50:10.772Z - info: Using extension sample-template
    2019-03-24T19:50:10.780Z - debug: Creating samples is disabled
    2019-03-24T19:50:10.780Z - info: Using extension resources
    2019-03-24T19:50:10.784Z - info: Using extension public-templates
    2019-03-24T19:50:10.796Z - debug: Extension public-templates was disabled
    2019-03-24T19:50:10.800Z - info: fs store is persisting using fs
    2019-03-24T19:50:10.800Z - info: fs store is synchronizing using fs
    2019-03-24T19:50:10.821Z - info: fs store is loading data
    2019-03-24T19:50:10.998Z - debug: fs store sync is configured to use polling for files watcher
    2019-03-24T19:50:11.257Z - info: fs store is initialized successfully
    2019-03-24T19:50:11.299Z - info: Creating default express app.
    2019-03-24T19:50:11.406Z - debug: Reading ssl certificate from /app/node_modules/jsreport-express/certificates/jsreport.net.cert
    2019-03-24T19:50:11.424Z - info: jsreport server successfully started on https port: 5489
    2019-03-24T19:50:11.425Z - info: jsreport server successfully started on http port: 5488
    2019-03-24T19:50:11.427Z - info: fs store emits sockets to synchronize underlying changes with studio
    2019-03-24T19:50:11.548Z - info: Verifying license key free
    2019-03-24T19:50:12.179Z - info: Using enterprise trial license
    2019-03-24T19:50:12.190Z - info: reporter initialized
    2019-03-24T19:50:56.773Z - info: Starting rendering request 1 (user: null)
    2019-03-24T19:50:56.776Z - info: Rendering template { name: Main, recipe: phantom-pdf, engine: jsrender, preview: true }
    2019-03-24T19:50:56.778Z - debug: Adding sample data S1xaFZ0M_V
    2019-03-24T19:50:56.779Z - debug: Resources not defined for this template.
    2019-03-24T19:50:56.783Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:57.015Z - debug: Executing script statementGenerator.js
    2019-03-24T19:50:58.560Z - debug: beforeRender - Building report for payee with Id 123456 for period Jan 01 2018 - Dec 01 2018
    2019-03-24T19:50:58.560Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:58.584Z - debug: Replaced assets ["main.css"]
    2019-03-24T19:50:58.598Z - debug: Rendering child template Summary
    2019-03-24T19:50:58.599Z - info: Starting rendering request 2 (user: null)
    2019-03-24T19:50:58.600Z - debug: Rendering child template TransactionDetails
    2019-03-24T19:50:58.600Z - info: Starting rendering request 3 (user: null)
    2019-03-24T19:50:58.603Z - debug: Rendering child template SummaryByWork
    2019-03-24T19:50:58.603Z - info: Starting rendering request 4 (user: null)
    2019-03-24T19:50:58.604Z - debug: Rendering child template SummaryByIncomeGroup
    2019-03-24T19:50:58.604Z - info: Starting rendering request 5 (user: null)
    2019-03-24T19:50:58.606Z - debug: Rendering child template SummaryByIncomeType
    2019-03-24T19:50:58.606Z - info: Starting rendering request 6 (user: null)
    2019-03-24T19:50:58.607Z - debug: Rendering child template SummaryByIncomeSource
    2019-03-24T19:50:58.607Z - info: Starting rendering request 7 (user: null)
    2019-03-24T19:50:58.608Z - debug: Rendering child template SummaryByTerritory
    2019-03-24T19:50:58.609Z - info: Starting rendering request 8 (user: null)
    2019-03-24T19:50:58.610Z - info: Rendering template { name: Summary, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:58.611Z - info: Rendering template { name: TransactionDetails, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:58.612Z - info: Rendering template { name: SummaryByWork, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:58.612Z - info: Rendering template { name: SummaryByIncomeGroup, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:58.613Z - info: Rendering template { name: SummaryByIncomeType, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:58.614Z - info: Rendering template { name: SummaryByIncomeSource, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:58.615Z - debug: Inline data specified.
    2019-03-24T19:50:58.615Z - info: Rendering template { name: SummaryByTerritory, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:58.616Z - debug: Resources not defined for this template.
    2019-03-24T19:50:58.617Z - debug: Inline data specified.
    2019-03-24T19:50:58.617Z - debug: Resources not defined for this template.
    2019-03-24T19:50:58.618Z - debug: Inline data specified.
    2019-03-24T19:50:58.619Z - debug: Resources not defined for this template.
    2019-03-24T19:50:58.619Z - debug: Inline data specified.
    2019-03-24T19:50:58.620Z - debug: Resources not defined for this template.
    2019-03-24T19:50:58.620Z - debug: Inline data specified.
    2019-03-24T19:50:58.620Z - debug: Resources not defined for this template.
    2019-03-24T19:50:58.621Z - debug: Inline data specified.
    2019-03-24T19:50:58.622Z - debug: Resources not defined for this template.
    2019-03-24T19:50:58.622Z - debug: Inline data specified.
    2019-03-24T19:50:58.622Z - debug: Resources not defined for this template.
    2019-03-24T19:50:58.623Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:58.623Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:58.625Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:58.629Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:58.630Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:58.631Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:58.633Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:58.687Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:58.687Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:58.687Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:58.688Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:58.688Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:58.689Z - debug: Rendering engine jsrender
    2019-03-24T19:50:58.690Z - debug: Rendering engine jsrender
    2019-03-24T19:50:58.690Z - debug: Rendering engine jsrender
    2019-03-24T19:50:58.694Z - debug: Rendering engine jsrender
    2019-03-24T19:50:58.695Z - debug: Rendering engine jsrender
    2019-03-24T19:50:58.699Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:58.715Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:58.716Z - debug: Rendering engine jsrender
    2019-03-24T19:50:58.723Z - debug: Rendering engine jsrender
    2019-03-24T19:50:59.016Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.017Z - debug: Executing recipe html
    2019-03-24T19:50:59.018Z - debug: Skipping storing report.
    2019-03-24T19:50:59.019Z - info: Rendering request 2 finished in 420 ms
    2019-03-24T19:50:59.024Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.025Z - debug: Executing recipe html
    2019-03-24T19:50:59.025Z - debug: Skipping storing report.
    2019-03-24T19:50:59.026Z - info: Rendering request 6 finished in 420 ms
    2019-03-24T19:50:59.037Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.038Z - debug: Executing recipe html
    2019-03-24T19:50:59.038Z - debug: Skipping storing report.
    2019-03-24T19:50:59.039Z - info: Rendering request 4 finished in 436 ms
    2019-03-24T19:50:59.044Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.045Z - debug: Executing recipe html
    2019-03-24T19:50:59.046Z - debug: Skipping storing report.
    2019-03-24T19:50:59.047Z - info: Rendering request 5 finished in 442 ms
    2019-03-24T19:50:59.066Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.069Z - debug: Executing recipe html
    2019-03-24T19:50:59.070Z - debug: Skipping storing report.
    2019-03-24T19:50:59.073Z - info: Rendering request 3 finished in 472 ms
    2019-03-24T19:50:59.090Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.092Z - debug: Executing recipe html
    2019-03-24T19:50:59.093Z - debug: Skipping storing report.
    2019-03-24T19:50:59.095Z - info: Rendering request 7 finished in 488 ms
    2019-03-24T19:50:59.103Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.105Z - debug: Executing recipe html
    2019-03-24T19:50:59.105Z - debug: Skipping storing report.
    2019-03-24T19:50:59.106Z - info: Rendering request 8 finished in 497 ms
    2019-03-24T19:50:59.111Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:59.112Z - debug: Rendering engine jsrender
    2019-03-24T19:50:59.121Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.124Z - debug: Rendering child template RoyaltiesStatement
    2019-03-24T19:50:59.124Z - info: Starting rendering request 9 (user: null)
    2019-03-24T19:50:59.127Z - info: Rendering template { name: RoyaltiesStatement, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:59.129Z - debug: Inline data specified.
    2019-03-24T19:50:59.129Z - debug: Resources not defined for this template.
    2019-03-24T19:50:59.130Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:59.145Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:59.145Z - debug: Rendering engine jsrender
    2019-03-24T19:50:59.171Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.174Z - debug: Executing recipe html
    2019-03-24T19:50:59.175Z - debug: Skipping storing report.
    2019-03-24T19:50:59.176Z - info: Rendering request 9 finished in 52 ms
    2019-03-24T19:50:59.193Z - debug: Executing recipe phantom-pdf
    2019-03-24T19:50:59.230Z - debug: Starting child request to render pdf header
    2019-03-24T19:50:59.231Z - info: Starting rendering request 10 (user: null)
    2019-03-24T19:50:59.233Z - info: Rendering template { name: Main, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:50:59.234Z - debug: Inline data specified.
    2019-03-24T19:50:59.234Z - debug: Resources not defined for this template.
    2019-03-24T19:50:59.235Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:59.248Z - debug: Executing script statementGenerator.js
    2019-03-24T19:50:59.269Z - debug: beforeRender - Building report for payee with Id 123456 for period Jan 01 2018 - Dec 01 2018
    2019-03-24T19:50:59.270Z - debug: Executing script helperFunctions.js
    2019-03-24T19:50:59.333Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:50:59.333Z - debug: Rendering engine jsrender
    2019-03-24T19:50:59.342Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:50:59.346Z - debug: Executing recipe html
    2019-03-24T19:50:59.348Z - debug: Skipping storing report.
    2019-03-24T19:50:59.351Z - debug: Executing script anonymous
    2019-03-24T19:51:05.316Z - debug: prepareStatementCSV complete. returning  records.
    2019-03-24T19:51:05.316Z - debug: afterRender - Report creation completed successfully.
    2019-03-24T19:51:05.317Z - info: Rendering request 10 finished in 6086 ms
    2019-03-24T19:51:05.318Z - debug: Starting child request to render pdf footer
    2019-03-24T19:51:05.319Z - info: Starting rendering request 11 (user: null)
    2019-03-24T19:51:05.320Z - info: Rendering template { name: Main, recipe: html, engine: jsrender, preview: true }
    2019-03-24T19:51:05.321Z - debug: Inline data specified.
    2019-03-24T19:51:05.321Z - debug: Resources not defined for this template.
    2019-03-24T19:51:05.323Z - debug: Executing script helperFunctions.js
    2019-03-24T19:51:05.372Z - debug: Executing script statementGenerator.js
    2019-03-24T19:51:05.391Z - debug: beforeRender - Building report for payee with Id 123456 for period Jan 01 2018 - Dec 01 2018
    2019-03-24T19:51:05.391Z - debug: Executing script helperFunctions.js
    2019-03-24T19:51:05.411Z - debug: Base url not specified, skipping its injection.
    2019-03-24T19:51:05.412Z - debug: Rendering engine jsrender
    2019-03-24T19:51:05.422Z - debug: Compiled template not found in the cache, compiling
    2019-03-24T19:51:05.459Z - debug: Executing recipe html
    2019-03-24T19:51:05.461Z - debug: Skipping storing report.
    2019-03-24T19:51:05.462Z - debug: Executing script anonymous
    2019-03-24T19:51:05.526Z - debug: prepareStatementCSV complete. returning  records.
    2019-03-24T19:51:05.526Z - debug: afterRender - Report creation completed successfully.
    2019-03-24T19:51:05.527Z - info: Rendering request 11 finished in 208 ms
    


  • You use the latest jsreport-aws-s3-storage from npm, right?
    Can you share also the jsreport.config.json content?

    So far I cannot replicate this. Based on your logs, the extension gets disabled because blobStorage.provider !== aws-s3-storage



  • Hi, yes it should be the latest version of jsreport-aws-s3-storage.

    Here is the jsreport.config.json content:

    {
      "extensions": {
        "authentication": {
          "cookieSession": {
            "secret": "<your strong secret here>"
          },
          "admin": {
            "username": "admin",
            "password": "password"
          },
          "enabled": false
        },
        "scripts": {
          "timeout": 40000,
          "strategy": "http-server",
          "allowedModules": ["jsreport", "jsrender", "jquery", "request", "express", "aws-sdk", "process", "jsreport-core", "jsreport-aws-s3-storage"]
        },
        "sample-template": {
          "createSamples": false
        },
        "express": {
          "inputRequestLimit": "250mb"
        },
        "assets": {
          "allowedFiles" : "/highcharts/js/themes/**.js"
        }
      },
      "httpPort": 5488,
      "httpsPort": 5489,
      "certificate": {
        "key": "~/.ssh/jsreport.key",
        "cert": "~/.ssh/jsreport.cer"
      },
      "store": {
        "provider": "fs"
      },
      "blobStorage": {
        "provider": "fs"
      },
      "logger": {
        "console": {
          "transport": "console",
          "level": "debug"
        },
        "file": {
          "transport": "file",
          "level": "info",
          "filename": "logs/reporter.log"
        },
        "error": {
          "transport": "file",
          "level": "error",
          "filename": "logs/error.log"
        }
      },
      "allowLocalFilesAccess": true,
      "templatingEngines": {
        "timeout": 10000,
        "strategy": "http-server"
      },
      "chrome": {
        "timeout": 40000
      },
      "phantom": {
        "strategy": "phantom-server",
        "defaultPhantomjsVersion": "2.1.1"
      },
      "freeze": {
        "hardFreeze": false
      }
    }
    

    In my original post, you can see that { blobStorage: { provider: 'aws-s3-storage' } }.



  • Please share the whole init code. The config is fine, the problem will be probably in the init code



  • I'm just using the default server.js built in to jsreports. Unless I'm misunderstanding what you are asking for?



  • You originally posted some code that was not the default built in.

    I mean this is not the built-in

     var jsreport_core = require('jsreport-core') ({ blobStorage: { provider: 'aws-s3-storage' } });
        jsreport_core.use(require('jsreport-aws-s3-storage')({
                "accessKeyId":  process.env.S3_SECRET_ACCESS_KEY,
    			"secretAccessKey":  process.env.S3_ACCESS_KEY_ID,
    			"bucket": process.env.S3_BUCKET_NAME,
    			"s3Options": {}
        }));
    


  • Ah I see what you are asking... here is the file

    const AWS = require('aws-sdk');
    const process = require('process');
    
    
    async function beforeRender(req, res, done) {
        //filter out script execution for phantom header & footer
        if (req.options.isChildRequest)
          return done();
        
        console.log('beforeRender - Building report for payee with Id ' + req.data.header.payeeId + ' for period ' + req.data.header.reportingPeriodFrom + ' - ' + req.data.header.reportingPeriodTo);
        done();
    }
    
    function afterRender(req, res, done) {
        //filter out script execution for phantom header & footer
        if (req.options.isChildRequest)
          return done();
    
        // Create CSV
        prepareStatementCSV(req, res);
        
        // Save pdf to S3 bucket - Method 1
        var jsreport_core = require('jsreport-core') ({ blobStorage: { provider: 'aws-s3-storage' } });
        jsreport_core.use(require('jsreport-aws-s3-storage')({
            "accessKeyId":  process.env.S3_SECRET_ACCESS_KEY,
    		"secretAccessKey":  process.env.S3_ACCESS_KEY_ID,
    		"bucket": process.env.S3_BUCKET_NAME,
    		"s3Options": {}
        }));
    
        console.log("afterRender - Report creation completed successfully.");
        done();
    }
       
    


  • Ah ok, you got it wrong. You are now trying to apply an extension in custom jsreport script...
    What you should do is:

    1. npm install jsreport-aws-s3-storage
    2. alter jsreport.config.json with
    {
    	"blobStorage": {  
    		"provider": "aws-s3-storage"
    	},
    	"extensions": {
    		"aws-s3-storage": {
    			"accessKeyId": "...",
    			"secretAccessKey": "...",
    			"bucket": "...",
    			"s3Options": {...}
    		}
    	}
    }
    

    In case you want to use some custom environment variables, apply them in the server.js

    const jsreport = require('jsreport')({
      blobStorage: { provider: 'aws-s3-storage' },
      extensions: {
        'aws-s3-storage': {
          'accessKeyId': process.env.S3_SECRET_ACCESS_KEY,
          'secretAccessKey': process.env.S3_ACCESS_KEY_ID,
          'bucket': process.env.S3_BUCKET_NAME,
          's3Options': {}
        }
      }
    })
    
    if (process.env.JSREPORT_CLI) {
      module.exports = jsreport
    } else {
      jsreport.init().then(() => {
        // running
      }).catch((e) => {
        // error during startup
        console.error(e.stack)
        process.exit(1)
      })
    }
    
    1. in your render request instruct reports extension to save the output into blob storage
       {
          "template": { "shortid" : "g1PyBkARK" },
          "data" : { ... },
          "options": {
              "reports": { "save": true }
          }
       }
    

    https://jsreport.net/learn/reports
    https://jsreport.net/learn/blob-storages



  • Hmm ok that seems to have fixed some of it! It now loads my keys into aws-s3-storage which is printing out in the logs. But when I log in to AWS, the PDF file is not uploaded to the S3 bucket. I know the bucket name and keys are correct since I am using them elsewhere to upload a CSV successfully and I did double check that {"save": true}. Any other ideas?



  • Share the startup logs and render logs again. This time make just simple render request like this

    {
      "template": {
        "content": "foo",
        "recipe": "html",
        "engine": "none"
      },
      "options": {
         "reports": { "save": true } 
      }
    }
    

    To better know what is going on you can also put a console.log here and here



  • Hi, I'm not sure if I have messed something else up, but this is the error I get when I run what you have requested:

    error: Error when processing render request The authorization header is malformed; the Credential is mal-formed; expecting "<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request". AuthorizationHeaderMalformed: The authorization header is malformed; the Credential is mal-formed; expecting "<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request".
        at Request.extractError (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/services/s3.js:583:35)
        at Request.callListeners (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
        at Request.emit (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
        at Request.emit (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/request.js:683:14)
        at Request.transition (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/request.js:22:10)
        at AcceptorStateMachine.runTo (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/state_machine.js:14:12)
        at /app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/state_machine.js:26:10
        at Request.<anonymous> (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/request.js:38:9)
        at Request.<anonymous> (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/request.js:685:12)
        at Request.callListeners (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
        at Request.emit (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
        at Request.emit (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/request.js:683:14)
        at Request.transition (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/request.js:22:10)
        at AcceptorStateMachine.runTo (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/state_machine.js:14:12)
        at /app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/state_machine.js:26:10
        at Request.<anonymous> (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/request.js:38:9)
        at Request.<anonymous> (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/request.js:685:12)
        at Request.callListeners (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
        at callNextListener (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
        at IncomingMessage.onEnd (/app/node_modules/jsreport-aws-s3-storage/node_modules/aws-sdk/lib/event_listeners.js:294:13)
        at IncomingMessage.emit (events.js:194:15)
        at IncomingMessage.EventEmitter.emit (domain.js:441:20)
    2019-03-25T16:58:04.405Z - error: Error during processing request at https://localhost:5489/api/report
    

    I am walking through the s3.js file now to see if I can figure out where this is breaking.



  • You seem to have your keys switched based on your the very first post

       "accessKeyId":  process.env.S3_SECRET_ACCESS_KEY,
    			"secretAccessKey":  process.env.S3_ACCESS_KEY_ID,
    


  • 😳 Wow. That fixed it! Amazing amazing!

    One last question... When uploading the PDF to S3, it sets random characters for the name. Is there another place I am supposed to be setting the name?

    {
      "template": {
        "name": "Main" 
      },
      "options": {
        "reportName": "myreport",
        "reports": { "save": true }
      },
      "data": {...}
    }
    


  • This is not configurable at this moment. We have it in the backlog
    https://github.com/jsreport/jsreport/issues/458

    You can fork the extension and just change two lines I guess, if you are in that need
    https://github.com/jsreport/jsreport-aws-s3-storage/blob/master/lib/main.js#L48



  • Ok I will consider a couple options, thanks so much for all your help!


Log in to reply
 

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