, , , . , , , . , , - , .
, npm. , . , , . Github:
github.com/mezis/fineuploader-rails
github.com/zakgrant/fine-uploader-rails
, .
javascript. "fine-uploader.coffee" - :
$ ->
uploader = new (qq.FineUploader)(
element: document.getElementById('fine-uploader')
request:
endpoint: '/upload'
params:
authenticity_token: $('#fine-uploader').data('authenticity-token')
template: 'template-name'
chunking:
enabled: true
mandatory: true
success:
endpoint: "/upload/finish"
)
, , , , .
"" , , .
post 'upload', to: 'uploads#create'
. , , .
uploads :
def create
file = params[:qqfile]
respond_to do |format|
format.json {
render json: { success: true }
}
end
end
( ), - qqfile. , . , . , , , ( dosc, - , refile).
, 7- javascript. CSRF.
, chunking ( ), , . , , - qquuid, params. , , , , . , , qquuid, , . :
Attachment.new(params[:qqfile], params[:qquuid])
, , ( , , ).
Attachment.where(qquuid: params[:qquuid]).combine_them_all
create , , ( , ) "", ,
chunking:
success:
endpoint: "/upload/finish"
( , ) . . , , , "true".
, json. , , ( json), , . , , - ( json ). , ( autoRetry true).
(haml):
#fine-uploader{"data- authenticity-token" => form_authenticity_token}
%script#template-name
Here goes the template
, , ( ). , , , , , qquuid . params , CSRF "create" uploads.
. , -.
EDIT: , Panczo