lundi 30 avril 2018

How to reflect the changes of a dynamically changing variable in a controller function to views?

During form submission, i am uploading a file to s3. In the uploading function i am trying to track upload progress. My controller sample code is bellow.

file = File.open('/path/to/file', 'r')
count = 0
obj = s3.buckets['my-bucket'].objects['object-key']
obj.write(:content_length => file.size) do |buffer, bytes|
  buffer.write(file.read(bytes))
  count = count +1
end
file.close

The only remaining task is, How can I reflect the changes happening to the count variable in views in real time.

Aucun commentaire:

Enregistrer un commentaire