Need to ask questions - Create Google Group around axlsx? #63

Closed
bruparel opened this Issue Mar 24, 2012 · 5 comments

Comments

Projects
None yet
2 participants
@bruparel

Hello Randy,
I think this is a wonderful Gem fulfilling a practical requirement. I need to ask some basic questions and hate to open up an issue for it. I can do it if that does not bother you. But these questions are not centered around "issues" with the Gem itself but rather how to use it for solving our problems. Here is an example for a real question that I have:

Your blog post, the example.rb file and Readme file all use a Tempfile to create a temporary file object for streaming to user's browswer. I am using Heroku for my production environment which forbids writing of files to the server. I need a generic way to get around it for "axlsx". I do the following for writing a "CSV" file:

require 'csv'
csv_string  = CSV.generate do |csv|
  ... write to the csv_string using block variable csv
end

# send it to the browser
file_name = @type_well.name.gsub(/\s+/,'_') + ".csv"
send_data csv_string,
        :type => 'text/csv; charset=iso-8859-1; header=present',
        :disposition => "attachment; filename=#{file_name}"

Here, the @type_well is an instance variable with a name column (property).

Can something similar be done for streaming the file to user's browser WITHOUT writing a Tempfile since Heroku does not allow it?

Thanks.

Bharat

@bruparel

This comment has been minimized.

Show comment Hide comment
@bruparel

bruparel Mar 24, 2012

Hello Randy,
I have figured this out. It turns out that Heroku Cedar doesn't really care where you write a temporary file as long as you don't expect it to survive the current request, so my code works just fine on Heroku.

However, I would like to propose that you start a Google Group for question/answers.

Thanks.

Bharat

Hello Randy,
I have figured this out. It turns out that Heroku Cedar doesn't really care where you write a temporary file as long as you don't expect it to survive the current request, so my code works just fine on Heroku.

However, I would like to propose that you start a Google Group for question/answers.

Thanks.

Bharat

@bruparel bruparel closed this Mar 24, 2012

@randym

This comment has been minimized.

Show comment Hide comment
@randym

randym Mar 25, 2012

Owner

Hi @bruparel

Did you know you can also use to_stream when serializing the package? This creates a StringIO object that you can return to the browser, save to a database, save as a flat file for later download etc.

As you are on Heroku - I don't thin this is available for you, but you might also be interested in this old, but interesting post about serving files:

http://www.therailsway.com/2009/2/22/file-downloads-done-right/

Finally:

Here is the google group - but if you want quick answers, I am usually on IRC (freenode) at #axlsx or #travis
Warmest regards

Randy

Owner

randym commented Mar 25, 2012

Hi @bruparel

Did you know you can also use to_stream when serializing the package? This creates a StringIO object that you can return to the browser, save to a database, save as a flat file for later download etc.

As you are on Heroku - I don't thin this is available for you, but you might also be interested in this old, but interesting post about serving files:

http://www.therailsway.com/2009/2/22/file-downloads-done-right/

Finally:

Here is the google group - but if you want quick answers, I am usually on IRC (freenode) at #axlsx or #travis
Warmest regards

Randy

@bruparel

This comment has been minimized.

Show comment Hide comment
@bruparel

bruparel Mar 26, 2012

Thanks Randy. I was able to tweak your code in your blog post and make it work on Heroku. Heroku Cedar stack does not care about where you write the file as long as you don't expect it to survive the current request/response cycle. So it works just fine.
Regards,
Bharat


From: Randy Morgan reply@reply.github.com
To: Bharat Ruparel bcruparel@yahoo.com
Sent: Sunday, March 25, 2012 4:43 AM
Subject: Re: [axlsx] Need to ask questions - Create Google Group around axlsx? (#63)

Hi @bruparel

Did you know you can also use to_stream when serializing the package? This creates a StringIO object that you can return to the browser, save to a database, save as a flat file for later download etc.

As you are on Heroku - I don't thin this is available for you, but you might also be interested in this old, but interesting post about serving files:

http://www.therailsway.com/2009/2/22/file-downloads-done-right/

Finally:

Here is the google group - but if you want quick answers, I am usually on IRC (freenode) at #axlsx or #travis
Warmest regards

Randy


Reply to this email directly or view it on GitHub:
#63 (comment)

Thanks Randy. I was able to tweak your code in your blog post and make it work on Heroku. Heroku Cedar stack does not care about where you write the file as long as you don't expect it to survive the current request/response cycle. So it works just fine.
Regards,
Bharat


From: Randy Morgan reply@reply.github.com
To: Bharat Ruparel bcruparel@yahoo.com
Sent: Sunday, March 25, 2012 4:43 AM
Subject: Re: [axlsx] Need to ask questions - Create Google Group around axlsx? (#63)

Hi @bruparel

Did you know you can also use to_stream when serializing the package? This creates a StringIO object that you can return to the browser, save to a database, save as a flat file for later download etc.

As you are on Heroku - I don't thin this is available for you, but you might also be interested in this old, but interesting post about serving files:

http://www.therailsway.com/2009/2/22/file-downloads-done-right/

Finally:

Here is the google group - but if you want quick answers, I am usually on IRC (freenode) at #axlsx or #travis
Warmest regards

Randy


Reply to this email directly or view it on GitHub:
#63 (comment)

@bruparel

This comment has been minimized.

Show comment Hide comment
@bruparel

bruparel Mar 26, 2012

By the way, where is the google group?
:)


From: Randy Morgan reply@reply.github.com
To: Bharat Ruparel bcruparel@yahoo.com
Sent: Sunday, March 25, 2012 4:43 AM
Subject: Re: [axlsx] Need to ask questions - Create Google Group around axlsx? (#63)

Hi @bruparel

Did you know you can also use to_stream when serializing the package? This creates a StringIO object that you can return to the browser, save to a database, save as a flat file for later download etc.

As you are on Heroku - I don't thin this is available for you, but you might also be interested in this old, but interesting post about serving files:

http://www.therailsway.com/2009/2/22/file-downloads-done-right/

Finally:

Here is the google group - but if you want quick answers, I am usually on IRC (freenode) at #axlsx or #travis
Warmest regards

Randy


Reply to this email directly or view it on GitHub:
#63 (comment)

By the way, where is the google group?
:)


From: Randy Morgan reply@reply.github.com
To: Bharat Ruparel bcruparel@yahoo.com
Sent: Sunday, March 25, 2012 4:43 AM
Subject: Re: [axlsx] Need to ask questions - Create Google Group around axlsx? (#63)

Hi @bruparel

Did you know you can also use to_stream when serializing the package? This creates a StringIO object that you can return to the browser, save to a database, save as a flat file for later download etc.

As you are on Heroku - I don't thin this is available for you, but you might also be interested in this old, but interesting post about serving files:

http://www.therailsway.com/2009/2/22/file-downloads-done-right/

Finally:

Here is the google group - but if you want quick answers, I am usually on IRC (freenode) at #axlsx or #travis
Warmest regards

Randy


Reply to this email directly or view it on GitHub:
#63 (comment)

@randym

This comment has been minimized.

Show comment Hide comment
@randym

randym Mar 27, 2012

Owner

that would be good to pass on, wouldn't it!

http://groups.google.com/group/axlsx

Owner

randym commented Mar 27, 2012

that would be good to pass on, wouldn't it!

http://groups.google.com/group/axlsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment