-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
How do you actually download a tarball? #559
Comments
https://hyper.rs/guides/1/client/basic/ has some detail on how to stream payloads. They have an example here: https://github.com/hyperium/hyper/blob/master/examples/client.rs#L64-L76 Streaming like this will be a much better approach than trying to hold the entire payload in memory at once. @XAMPPRocky, it does mean we'll need to adapt to this breaking change in
|
(This appears to be a duplicate of #493) |
Sorry to ask a follow up, but the example provided:
res is a |
I was able to stream a repo into a tarball on disk utilizing the following. use http_body_util::BodyExt;
let mut resp = octocrab
.repos(REPO_OWNER, REPO_NAME)
.download_tarball(Reference::Branch("BRANCH_NAME".to_owned()))
.await?;
let body = resp.body_mut();
let mut file = File::create("test.tar.gz")?;
while let Some(next) = body.frame().await {
let frame = next?;
if let Some(chunk) = frame.data_ref() {
file.write_all(&chunk)?;
}
} In order to get |
The
download_tarball
method returns an object, once awaited and unwrapped, is aResponse<Body>
. I'm not sure how to turn this into an actual workingtar.gz
file on my computer, since thehyper::body::to_bytes
method has been deprecated recently.The text was updated successfully, but these errors were encountered: