How can I send binary data from Sinatra?
you can just return binary data:
get '/binary' do
content_type 'application/octet-stream'
"\x01\x02\x03"
end
Groovy - Grab - download failed
It looks like your Grape settings are set only to look in your local .m2
directory for the library. Check your grapeConfig.xml
configuration file. (If you don't have one, you can create it--it should go in the same directory where your groovysh.history
and grapes
cache directory are created by Groovy.) You can copy the example file shown on the Groovy Grape reference page.
If that doesn't help, I would try deleting your grapes
cache directory and try it again.
download csv file to computer
You need to set headers to indicate what the browser should be doing with the resulting file.
send_data file, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => "attachment;data=#{csv_file}.csv"
However, it would have to be written first, to the server, and then downloaded. You might find this answer helpful: Ruby 1.9.2 export a CSV string without generating a file
Related Topics
Does Rails Come with a "Not Authorized" Exception
I18N: Error Message Localization for Particular Model
How to Stop God from Leaving Stale Resque Worker Processes
Ruby - Array.Join Versus String Concatenation (Efficiency)
Rails 4 Strong Parameters Failing When Creating Instances in Rails Console
How to Get Words Frequency in Efficient Way with Ruby
How to Sort a Ruby Hash Alphabetically by Keys
How to Pluck Email from Array of Users
Ruby Sandboxing VS. Integrating a Scripting Language
How to Set a Cookie with a (Ruby) Rack Middleware Component
Heroku Rejecting Push in Mature Application (Pre-Receive Hook Declined)
Is There a Function Like String#Scan, But Returning Array of Matchdatas
Ruby Array to Hash: Each Element the Key and Derive Value from It