我按照本指南通过 AJAX 获取拖放文件上传:http: //dannemanne.com/posts/drag-n-drop_upload_that_works_with_ror_and_paperclip
使用 WebBrick 在我的开发环境中一切正常,但如果我部署到 PhusionPassenger,我会得到:
Paperclip::AdapterRegistry::NoHandlerError (No handler found for #<PhusionPassenger::Utils::RewindableInput:0x000000041aef38 @io=#<PhusionPassen...
我在我的控制器中使用它:
before_filter :parse_raw_upload, :only => :bulk_submissions
def bulk_submissions
...
@submission = Submission.create!(url: "", file: @raw_file, description: "Please edit this description", work_type: "other", date_completed: DateTime.now.to_date)
...
end
private
def parse_raw_upload
if env['HTTP_X_FILE_UPLOAD'] == 'true'
@raw_file = env['rack.input']
@raw_file.class.class_eval { attr_accessor :original_filename, :content_type }
@raw_file.original_filename = env['HTTP_X_FILE_NAME']
@raw_file.content_type = env['HTTP_X_MIME_TYPE']
end
end
查看请求本身,所有标头都已设置(X_MIME_TYPE,X_FILE_NAME)等。
有任何想法吗?
提前致谢!