-
Notifications
You must be signed in to change notification settings - Fork 53
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
Upload binary files to an existing release #56
Comments
Yes, this is somewhat cumbersome in library(gh)
## Get a list of releases
## https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
rels <- gh(
"/repos/:owner/:repo/releases",
owner = "gh-testing",
repo = "myrepo"
)
## Get a single release
## https://developer.github.com/v3/repos/releases/#get-a-single-release
rel <- gh(
"/repos/:owner/:repo/releases/:id",
owner = "gh-testing",
repo = "myrepo",
id = rels[[1]]$id
)
## Extract the upload url, we don't support URI templates (yet),
## so you need to handle the {} part manually.
upload_url <- gsub("\\{[^\\}]+}", "", rel$upload_url)
## Upload a file
## https://developer.github.com/v3/repos/releases/#upload-a-release-asset
cat("This will be uploaded\n", file = "asset.txt")
gh(
paste0("POST ", upload_url, "?name=asset.txt"),
readBin("asset.txt", raw(), file.info("asset.txt")$size),
.send_headers = c("Content-Type" = "text/plain")
) |
Unfortunately, I experience the same problems. I tried to upload the binary with the following MIME types:
With my code I was able to upload and open a PDF using the MIME type Just like before, the size of the upload shown in GitHub and downloaded is larger: my test 93K binary increases to 128K. Not really important, but for the sake of reproducibility, I uploaded to a draft release. |
It seems that the What's your |
Using MSYS2 zsh:
where:
gives Note that I have tried with a number of different test files. |
Finally this is now fixed. E.g. binary <- "~/Downloads/clipboard.exe"
gh(
paste0("POST https://uploads.github.com/repos/gaborcsardi/playground/releases/233390/assets",
"?name=clipboard.exe"),
readBin(binary, raw(), file.info(binary)$size),
.send_headers = c("Content-Type" = "application/vnd.microsoft.portable-executable")
) |
Finally I was able to check your code. I confirm it works for me too.
So it seems that R code was executed in Linux and the download test was executed in Windows. |
I would like to a upload binary file to an existing release on GitHub, using the API published here.
developer.github.com/v3/repos/releases
Is it possible to upload a binary with a
gh()
POST?In the meantime, I have tried with the R
curl
package. AssumingRELEASEID
is the release ID to upload to, I might use:The upload appears to succeed, but, when I download the file
app.exe
, it is corrupted.I do not experience problems with other MIME types, e.g. PDFs.
Also, using
curl.exe
from the shell,app.exe
does not break.The text was updated successfully, but these errors were encountered: