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.
Ace the Technical Interview
- Easily find the gaps in your knowledge
- Get customized lessons based on where you are
- Take consistent action everyday
- Builtin accountability to keep you on track
- You will solve bigger problems over time
- Get the job of your dreams
Take the 30 Day Coding Skills Challenge
Gain confidence to attend the interview