Sinatra Beyond Basics : Send a Zip File
To zip files and send the zipped file to the client.
Create a bogus.txt file with:
This is a test file.
Crete a readme.txt file with:
This is a readme.
Create a tester.zip in the current directory that includes bogus.txt and readme.txt.
Create zipper.rb with:
require 'sinatra' get '/' do filename ="./tester.zip" send_file(filename, :filename => "test.zip", :type => "application/zip") end
Run the Sinatra app, it will send the zip file when you do a GET.
In this article you learned how to send a zip file in a Sinatra app.