Commit d5451e64

mo k <mo@mokhan.ca>
2012-10-14 16:25:32
add configuration for nginx-fast-upload-module
1 parent 229c90f
Changed files (3)
app/views/creations/_form.html.erb
@@ -5,7 +5,7 @@
     });
   </script>
 <% end %>
-<%= form_for(@creation, :html => {:multipart => true, :class => "form-horizontal"}) do |f| %>
+<%= form_for(@creation, :url => fast_upload_path, :html => {:multipart => true, :class => "form-horizontal"}) do |f| %>
   <fieldset>
     <div class="control-group">
       <%= f.label :name, :class => "control-label" %>
config/nginx.conf
@@ -48,5 +48,19 @@ http {
       add_header ETag "";
       break;
     }
+    location /creations/fast_upload {
+      upload_pass @fast_upload_endpoint;
+      upload_store /home/cakeside/apps/www.cakeside.com/shared/uploads_tmp 1;
+      upload_store_access user:rw group:rw all:r;
+      upload_set_form_field creation[image] "$upload_file_name";
+      upload_set_form_field creation[content_type] "$upload_content_type";
+      upload_set_form_field creation[filepath] "$upload_tmp_path";
+
+      upload_pass_form_field "^authenticity_token$|^format$";
+      upload_cleanup 400 404 499 500-505;
+    }
+    location @fast_upload_endpoint {
+      passenger_enabled on;
+    }
   }
 }
config/routes.rb
@@ -18,6 +18,7 @@ Cake::Application.routes.draw do
     resources :favorites, :only => [:index, :create]
     resources :comments, :only => [:index, :new, :create]
   end
+  match "creations/fast_upload" => "creations#create", :as => 'fast_upload', :method => "POST"
 
   # /profiles
   resources :profiles, :only => [:index, :show]