Sinatra Beyond Basics : Send a Zip File


To zip files and send the zipped file to the client.


Step 1

Create a bogus.txt file with:

This is a test file.

Step 2

Crete a readme.txt file with:

This is a readme.

Step 3

Create a in the current directory that includes bogus.txt and readme.txt.

Step 4

Create zipper.rb with:

require 'sinatra'

get '/' do
  filename ="./"

  send_file(filename, :filename => "", :type => "application/zip")

Step 5

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.

Related Articles

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

No spam ever. Unsubscribe anytime.