Я использую Rails 3.0.9, Devise 1.4 и Plupload 1.4.3.2 .Все отлично работает со временем выполнения HTML5.
Но когда я добавляю before_filter authenticate_user! к своему контроллеру приложения и переключаюсь на время выполнения флэш-памяти все идет плохо.
Когда я пытаюсь загрузить несколько изображений:
Started POST "/uploads" for 127.0.0.1 at 2011-06-29 12:58:48 +0200
Processing by UploadsController#create as JS
Parameters: {"Filename"=>"me_dark_ui_01.png", "name"=>"me_dark_ui_01.png", "_inzercia_session"=>"BAh7CEkiEF9jc3JmX3Rva2VuBjoGRUZJIjE0NjlmSkZCd25VMkl1UEFzTTFUVTUwTFVYTjRHYkJJSTlGKzBWTXFlSzc0PQY7AEZJIhl3YXJkZW4udXNlci51c2VyLmtleQY7AFRbCEkiCVVzZXIGOwBGWwZpB0kiIiQyYSQxMCQ4SkVLZGVja0dLVk5jbm10MEVoNmRPBjsAVEkiD3Nlc3Npb25faWQGOwBGIiUwY2Y1ZjM4MDRlMGEzOTM3MzQ5ZTQzM2RkNjk5MTc0Mg%253D%253D--b0e6653c44645e7db420dff1dd9908f4b8938e6d", "authenticity_token"=>"469fJFBwnU2IuPAsM1TU50LUXN4GbBII9F+0VMqeK74=", "upload_token"=>"07ea1a1ec4539436878b8e13ae6347164fcd3eac", "_http_accept"=>"application/javascript", "file"=>#<ActionDispatch::Http::UploadedFile:0x520bae0 @original_filename="me_dark_ui_01.png", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"me_dark_ui_01.png\"\r\nContent-Type: application/octet-stream\r\n", @tempfile=#<File:C:/Users/Deli/AppData/Local/Temp/RackMultipart20110629-4684-osz0l9>>, "Upload"=>"Submit Query"}
Completed in 21ms
Мои загрузки # создать действие
def create
@upload = Upload.new
@upload.photo = params[:file] if params.has_key?(:file)
# detect Mime-Type (mime-type detection doesn't work in flash)
@upload.photo_content_type = MIME::Types.type_for(params[:name]).to_s if params.has_key?(:name)
@upload.upload_token = params[:upload_token]
@upload.save!
strong textrespond_to :js
end
Настройки Plupload:
<% session_key_name = Rails.application.config.session_options[:key] %>
jQuery(document).ready(function() {
$("#uploader").pluploadQueue({
runtimes: 'flash',
url: '<%= uploads_path %>',
max_file_size: '10mb',
multiple_queues: true,
flash_swf_url: "/javascripts/plupload/plupload.flash.swf",
silverlight_xap_url: "/javascripts/plupload/plupload.silverlight.xap",
multipart: true,
multipart_params: {
'_http_accept': 'application/javascript',
'authenticity_token' : '<%= form_authenticity_token %>',
'upload_token' : '<%= @upload_token %>',
'<%= session_key_name %>' : encodeURIComponent('<%= u cookies[session_key_name] %>')
},
filters: [
{title: "Images", extensions: "jpg,jpeg,png"}
],
init: {
FileUploaded: function(up, file, info) {
eval(info["response"]);
}
}
});
});