waynehoover / s3_direct_upload

Direct Upload to Amazon S3 With CORS
MIT License
652 stars 333 forks source link

How to upload multiple files #222

Closed mazharoddin closed 8 years ago

mazharoddin commented 9 years ago

Hi, Thanks for this nice gem, I am able to upload single file directly to S3 using by following this tutorial http://www.akitaonrails.com/2014/03/26/heroku-tips-s3-direct-upload-carrierwave-sidekiq#.VZZJ7nWUclL, but I am not able to upload multiple files, I tried to change multiple: true option in view and js, but nothing is working for me, files are uploading S3, but only one image is showing if I submit the page.

Here is my view code

= s3_uploader_form as: "photo[image_url]", id: "s3-uploader", class: "pure-form pure-form-stacked"
        = file_field_tag :file, multiple: true

And Js code.

jQuery(function() {
  var s3_uploader = $("#s3-uploader");
  var uploader = s3_uploader.S3Uploader({
    progress_bar_target: $(".progress_bar"),
    allow_multiple_files: true,
  });

Please let me know how to implement multiple file upload functionality, it would be great to if there is sample code for multiple file upload

keyeh commented 8 years ago

Use callback_url. It should get the info from each file you upload.

For example:

<%= s3_uploader_form callback_url: new_document_url,
                     id: "s3_uploader",
                     callback_param: "document[file_url]",
                     expiration: 2.hours.from_now.utc.iso8601,
                     callback_method: "POST",
                     max_file_size: 10000.megabytes do %>

Document controller

class DocumentsController < ApplicationController
    def new
        @document = Document.create(file_params)
    end
mazharoddin commented 8 years ago

Thanks you, I will try and let you know