Skip to content

Instantly share code, notes, and snippets.

@tyhoff
Last active January 12, 2026 16:51
Show Gist options
  • Select an option

  • Save tyhoff/b757e6af83c1fd2b7b83057adf02c139 to your computer and use it in GitHub Desktop.

Select an option

Save tyhoff/b757e6af83c1fd2b7b83057adf02c139 to your computer and use it in GitHub Desktop.
Python requests HTTP PUT with tqdm progress bar
from tqdm import tqdm
from tqdm.utils import CallbackIOWrapper
file_path = os.path.abspath(__file__)
upload_url = https://some-bucket.s3.amazonaws.com
file_size = os.stat(file_path).st_size
with open(file_path, "rb") as f:
with tqdm(total=file_size, unit="B", unit_scale=True, unit_divisor=1024) as t:
wrapped_file = CallbackIOWrapper(t.update, f, "read")
requests.put(upload_url, data=wrapped_file)
@baichen99
Copy link

Great! This was very helpful to me

@Bumerang505
Copy link

Thank you very much!

@gauss-clb
Copy link

gauss-clb commented Jul 22, 2024

Good job!

@scottsavage
Copy link

This is the answer to not being able to stream binary files using requests. Thanks!!

@JScheumann
Copy link

Thank you <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment