ruby on rails - Reduce multiple file upload time -


i uploading multiple images , videos input[type='file'], upload takes lot of time. there way can reduce upload time. here current code:

paperclip settings

     has_attached_file :file, styles: lambda { |a| a.instance.check_file_type}   validates_attachment_content_type :file, content_type: [/\aimage\/.*\z/,/\avideo\/.*\z/]    def is_video?     file.content_type =~ %r(video)   end    def is_image?     file.content_type =~ %r(image)   end    def check_file_type     if is_image?       { :medium => { :geometry => "640x480" },       :thumb => { :geometry => "100x100#" } }     elsif is_video?       { :medium => { :geometry => "640x480", :format => 'mp4', :processors => [:transcoder] },       :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }}     else       {}     end   end 

_form.html.erb

<%= simple_form_for(@room, remote: true, format: :js, authenticity_token: true, html: {multipart: true}) |f| %>    *******other fields***********     <input id="video-selector" type="file" name="files[]" accept="video/*,image/*" capture="camcorder" hidden="true" class="hide" multiple                    onchange="$('#upload-file-info').addclass('label-info').append(this.files[0].name);"> <% end %> 

you can follow link upload multiple files https://www.sitepoint.com/asynchronous-multiple-file-upload-with-rails-and-dropzone-js/


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -