Download File from Google Drive/Docs Programmatically with R
[This article was first published on theBioBucket*, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Following up my lattest posting on how to download files from the cloud with R..Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
dl_from_GoogleD <- function(output, key, format) { ## Arguments: ## output = output file name ## key = Google document key ## format = output format (pdf, rtf, doc, txt..) ## Note: File must be shareable! require(RCurl) bin <- getBinaryURL(paste0("https://docs.google.com/document/d/", key, "/export?format=", format), ssl.verifypeer = FALSE) con <- file(output, open = "wb") writeBin(bin, con) close(con) message(noquote(paste(output, "read into", getwd()))) } # Example: dl_from_GoogleD(output = "dl_test.pdf", key = "1DdauvkcVm5XtRBkQIv1na8PeLAwpCBdW8pALCFpRWeM", format = "pdf") shell.exec("dl_test.pdf")
To leave a comment for the author, please follow the link and comment on their blog: theBioBucket*.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.