This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Mutwin Kraus (author)
Tue Oct 13 03:17:58 -0700 2009
| name | age | message | |
|---|---|---|---|
| |
.document | Sat May 30 11:34:59 -0700 2009 | |
| |
.gitignore | Sat May 30 11:34:59 -0700 2009 | |
| |
LICENSE | Sat May 30 11:34:59 -0700 2009 | |
| |
README.rdoc | Sat Jun 13 07:30:50 -0700 2009 | |
| |
Rakefile | Mon Jun 01 10:09:45 -0700 2009 | |
| |
VERSION | Tue Oct 13 03:14:57 -0700 2009 | |
| |
init.rb | Mon Jun 01 10:05:29 -0700 2009 | |
| |
lib/ | Tue Oct 13 03:13:38 -0700 2009 | |
| |
rack-uploads.gemspec | Tue Oct 13 03:17:58 -0700 2009 | |
| |
spec/ | Sat Jun 13 07:30:50 -0700 2009 |
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.







