Skip to content

Instantly share code, notes, and snippets.

@astatham
Created August 19, 2010 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astatham/537021 to your computer and use it in GitHub Desktop.
Save astatham/537021 to your computer and use it in GitHub Desktop.
imguRupload <- function(filename, title=NULL, caption=NULL, name=basename(filename), apikey="4feb29d00face5bc1b9dae536e15c373") {
require(RCurl)
require(RJSONIO)
if (length(filename)>1) stop("'filename' must be length 1.")
if (!file.exists(filename)) stop(filename, "does not exist!")
params <- list(key=apikey, image=fileUpload(filename), name=filename)
if (!is.null(title)) params[["title"]] <- title
if (!is.null(caption)) params[["caption"]] <- caption
fromJSON(rawToChar(postForm("http://api.imgur.com/2/upload.json", .params=params)))$upload
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment