Class | ActionController::UploadProgress::Progress |
In: |
lib/action_controller/upload_progress.rb
|
Parent: | Object |
Which means that it doesn’t yet work on all systems. We‘re still working on full compatibility. It’s thus not advised to use this unless you’ve verified it to work fully on all the systems that is a part of your environment. Consider this an extended preview.
Upload Progress abstracts the progress of an upload. It’s used by the multipart progress IO that keeps track of the upload progress and creating the application depends on. It contians methods to update the progress during an upload and read the statistics such as received_bytes, total_bytes, completed_percent, bitrate, and remaining_seconds
You can get the current Progress object by calling upload_progress instance method in your controller or view.
MIN_SAMPLE_TIME | = | 0.150 | Number of seconds between bitrate samples. Updates that occur more frequently than MIN_SAMPLE_TIME will not be queued until this time passes. This behavior gives a good balance of accuracy and load for both fast and slow transfers. | |
MIN_STALL_TIME | = | 10.0 | Number of seconds between updates before giving up to try and calculate bitrate anymore | |
MAX_SAMPLES | = | 20 | Number of samples used to calculate bitrate |
last_update_time | [R] | The last time the upload history was updated |
message | [RW] | A message you can set from your controller or view to be rendered in the upload_status_text helper method. If you set a messagein a controller then call session.update to make that message available to your upload_status action. |
received_bytes | [R] | Number bytes received from the multipart post |
total_bytes | [R] | Total number of bytes expected from the mutlipart post |
Calculates the bitrate in bytes/second. If the transfer is stalled or just started, the bitrate will be 0
Calculate the seconds remaining based on the current bitrate. Returns O seconds if stalled or if no bytes have been received
Resets the received_bytes, last_update_time, message and bitrate, but but maintains the total expected bytes