vendredi 28 août 2015

Multiple simultaneous remote file uploads ruby on rails

How can be multiple files upload simultaneous and check upload process ( I mean time left )

On rails application I have multiple text fields, they are for remote file urls like http://ift.tt/1WWBaOU etc and these all files should be downloaded to a temp_uploads folder.

for this I have written code in remotefiles controller like below.

def remotefiles
    params[:reference_file_url].each do |rfile|
        temp_file = File.new("/public/temp_uploads", "w")
        open(temp_file, 'wb') do |file|
            file << open(rfile).read()
        end
    end
end

where rfile is remote file url.

I also have defined route remotefiles to call it in ajax

my ajax call sends form data in serialize format and this controller uploads all files 1 by 1.

with this code i have to wait untill all files are uploaded to folder that is obviously not acceptable.( I mean client asked me to reduce wait time by uploading all files simultaneous )

is there any way to get it done, all my code is custom and is not using any gem

Aucun commentaire:

Enregistrer un commentaire