github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

mutle / rack-uploads

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 59
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (1)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (1)
    • v0.2.1
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Rack Upload handler with Nginx Upload Module support — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Bump version number in gemspec too 
mutle (author)
Tue Oct 13 03:17:58 -0700 2009
commit  a7f03a34207fabcf8604e7d1424679d8f161d751
tree    1c67f7addcdc0da8b08ce62beb36ccf4ab403263
parent  11942d3f47a22d624d944eebbfb5e4ad3c15cc87
rack-uploads /
name age
history
message
file .document Sat May 30 11:34:59 -0700 2009 Initial commit to rack-uploads. [mutle]
file .gitignore Sat May 30 11:34:59 -0700 2009 Initial commit to rack-uploads. [mutle]
file LICENSE Sat May 30 11:34:59 -0700 2009 Initial commit to rack-uploads. [mutle]
file README.rdoc Sat Jun 13 07:30:50 -0700 2009 rack-uploads now scans for uploads on all post ... [mutle]
file Rakefile Mon Jun 01 10:09:45 -0700 2009 gemspec [mutle]
file VERSION Tue Oct 13 03:14:57 -0700 2009 Version bump to 0.2.1 [mutle]
file init.rb Mon Jun 01 10:05:29 -0700 2009 preparing for first release [mutle]
directory lib/ Tue Oct 13 03:13:38 -0700 2009 Fix typo, thanks BrianTheCoder [mutle]
file rack-uploads.gemspec Tue Oct 13 03:17:58 -0700 2009 Bump version number in gemspec too [mutle]
directory spec/ Sat Jun 13 07:30:50 -0700 2009 rack-uploads now scans for uploads on all post ... [mutle]
README.rdoc

rack-uploads

rack-uploads is a middleware which receives uploads and stores them in in the Rack env for easy access.

It works with normal HTTP file uploads, as well as with the Nginx Upload Module.

All multipart params get replaced by a Rack::Uploads::UploadedFile, while still retaining access to the original parameter value.

Dependencies

Development dependencies:

  • rspec
  • rack-test

Usage

Sinatra

  use Rack::Uploads

  post "/uploads" do
    env['rack.uploads'].each do |upload|
      upload.mv('/some/path/#{upload.filename}')
    end
  end

Rails

  # config/environment.rb
  config.middleware.use "Rack::Uploads"

  # app/controller/uploads_controller.rb
  class UploadsController < ApplicationController
    def create
      request['rack.uploads'].each do |upload|
        upload.mv("#{RAILS_ROOT}/public/uploads/#{upload.filename}")
      end
    end
  end

Options

There are a few options you can pass to rack-uploads during initializiation:

:session_authorized => lambda { |req| req.params[‘secret’] == "sekrit" } - Only allow uploads with the parameter "secret" set to "sekrit"

:nginx => [{ :tmp_path => "_tmp_path", :filename => "_file_name" }] - Sets the suffixes of the nginx upload parameters

Copyright

Copyright © 2009 Mutwin Kraus. See LICENSE for details.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server