Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object#download_file Add Progress Callback #2901

Closed
1 of 2 tasks
foxtrod opened this issue Aug 17, 2023 · 3 comments
Closed
1 of 2 tasks

Object#download_file Add Progress Callback #2901

foxtrod opened this issue Aug 17, 2023 · 3 comments
Assignees
Labels
feature-request A feature should be added or improved. in-progress Work is in progress to resolve the issue.

Comments

@foxtrod
Copy link

foxtrod commented Aug 17, 2023

Describe the feature

Progress Callback for Object#download_file

Introduce a built-in mechanism within the Object#download_file that provides real-time feedback on the download progress just like in a Object#upload_file

Use Case

Seeing is Believing.

Currently, to get any sense of progress, I was left either diving deep into the AWS client logger or constantly pinging the file size, I've picked the second option and wondering how users of the gem are handling the progress (let me know in the comments). The Object#upload_file method has this awesome progress feedback, so why shouldn't Object#download_file have the same?

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

3.180.3

Environment details (OS name and version, etc.)

MacOs Ventura 13.3

@foxtrod foxtrod added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 17, 2023
@foxtrod
Copy link
Author

foxtrod commented Aug 17, 2023

Would be glad if i missed existing functionality that covers download progress, but if someone wonders I'm using next workaround:

download_thread = Thread.new do
  s3_object.download_file(destination, { thread_count: threads_count, mode: "get_range", chunk_size: chunk_size })
end

progress_thread = Thread.new do
  begin
    while download_thread.alive? # ping file size until download processing
      current_size = File.exist?(destination) ? File.size(destination) : 0
      progress_percentage = (current_size.to_f / expected_size) * 100

      puts "Downloaded: #{current_size} / #{expected_size} (#{progress_percentage.round(2)}%)"

      break if current_size >= expected_size

      sleep 1 # wait for a second before checking again
    end
  rescue => e
    logger.error(event: :progress_thread, error: e)
  end
end

download_thread.join 
progress_thread.join

@alextwoods alextwoods added in-progress Work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 18, 2023
@alextwoods alextwoods self-assigned this Aug 18, 2023
@jterapin
Copy link
Contributor

Resolved in #2902.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. in-progress Work is in progress to resolve the issue.
Projects
None yet
Development

No branches or pull requests

3 participants