1

Is it possible to create a new excel spreadsheet file and save it to an Amazon S3 bucket without first saving to a local filesystem?

For example, I have a Ruby on Rails web application which now generates Excel spreadsheets using the write_xlsx gem and saving it to the server's local file system. Internally, it looks like the gem is using Ruby's IO.copy_stream when it saves the spreadsheet. I'm not sure this will work if moving to Heroku and S3.

Has anyone done this before using Ruby or even Python?

Edward J. Stembler
  • 1,932
  • 4
  • 30
  • 53

2 Answers2

1

I found this earlier question, Heroku + ephemeral filesystem + AWS S3. So, it would seem this is not possible using Heroku. Theoretically, it would be possible using a service which allows adding an Amazon EBS.

Community
  • 1
  • 1
Edward J. Stembler
  • 1,932
  • 4
  • 30
  • 53
0

You have dedicated Ruby Gem to help you moving file to Amazon S3:

https://rubygems.org/gems/aws-s3

If you want more details about the implementation, here is the git repository. The documentation on the page is very complete, and explain how to move file to S3. Hope it helps.

Once your xls file is created, the library helps you create a S3Objects and store it into a Bucket (which you can also create with the library).

S3Object.store('keyOfYourData', open('nameOfExcelFile.xls'), 'bucketName')

If you want more choice, Amazon also delivered an official Gem for this purpose: https://rubygems.org/gems/aws-sdk

Jérôme
  • 8,016
  • 4
  • 29
  • 35
  • Okay, but from my understanding of Heroku, the excel file cannot be saved to the file system. Using the write_xlsx gem, closing the workbook saves the file to disk. How can this be accomplished using Heroku and S3? – Edward J. Stembler Jan 24 '15 at 02:14