Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Earlier today, @noamross posted to Twitter:
#rstats #lazyweb What's the R/httr/curl equivalent of
curl -F "file=@somefile.html" https://t.co/abbugLz9ZW
— Noam Ross (@noamross) May 3, 2018
The answer was a 1:1 “file upload” curl
to httr
translation:
httr::POST( url = "https://file.io", encode = "multipart", body = list(file = httr::upload_file("/some/path/to/file")), )
but I wanted to do more than that since Noam took 20 minutes out his day this week (with no advance warning) to speak to my intro-to-stats class about his work and R.
The Twitter request was (ultimately) a question on how to use R to post content to https://file.io. They have a really simple API, and the timespan from Noam’s request to the initial commit of a fully functional package was roughly 17 minutes. The end product included the ability to post files, strings and R data (something that seemed like a good thing to add).
Not too long after came a v0.1.0 release complete with tests and passing CRAN checks on all platforms.
Noam also suggested I do a screencast:
You should do a screencast of your process for this.
— Noam Ross (@noamross) May 3, 2018
I don’t normally do screencasts but had some conference call time so folks can follow along at home:
That’s not the best screencast in the world, but it’s very representative of the workflow I used. A great deal of boilerplate package machinations is accomplished with this bash
script.
I wasn’t happy with the hurried function name choices I made nor was I thrilled with the package title, description, tests and basic docs, so I revamped all those into another release. That took a while, mostly due to constantly triggering API warnings about being rate-limited.
So, if you have a 5 GB or less file, character vector or in-memory R data you’d like to ephemerally share with others, take the fileio package for a spin:
devtools::install_github("hrbrmstr/fileio") fileio::fi_post_text("TWFrZSBzdXJlIHRvIEAgbWUgb24gVHdpdHRlciBpZiB5b3UgZGVjb2RlIHRoaXM=") ## success key link expiry ## 1 TRUE n18ZSB https://file.io/n18ZSB 14 days
(bonus points if you can figure out what that seemingly random sequence of characters says).
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.