user1790300
user1790300

Reputation: 1735

Elastic Beanstalk: How to write files to a folder in my node.js project folder

I created an application on my local machine(mac os x) that generates a report and saves it to a folder in my web project folder. When I deploy the app., this folder should get published as well. Granted, no one should have access to this folder but the app. When I run the code to generate the report works fine on my local machine, but it seems to hang on elastic beanstalk. What do I need to do to make this work on the elastic beanstalk environment?

In a nutshell, I am using phantomjs to convert a dynamic webpage into a pdf file that gets emailed to the appropriate parties involved. Here is the code that generates the file:

page.viewportSize = { width: 2000, height: 800 };
//page.paperSize = { format: 'Letter', orientation: 'landscape', margin: '1cm' };
page.paperSize = { width: '1280px', height: '800px', margin: '0px' };
page.settings.localToRemoteUrlAccessEnabled = true;
page.settings.loadImages = true;
page.settings.javascriptEnabled = true;


page.open("http://example.com/report/" + args[1], function start(status) {
  if (status === 'fail'){
      phantom.exit(1);
      return;
  }

//page.render('/dev/stdout', { format: 'pdf' });
  page.render(fs.workingDirectory + '/tmp/' + args[3], { format: 'pdf' });
  phantom.exit();
  return;
});

Upvotes: 3

Views: 2640

Answers (1)

Brian
Brian

Reputation: 5491

The directory to which your ElasticBeanstalk application is deployed should be considered read-only after the deployment is complete. If you need to write files at run time, you should use a writeable directory such as /tmp.

Upvotes: 4

Related Questions