Skip to content
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

Move knitr::imgur_upload() to this package #83

Closed
yihui opened this issue Feb 8, 2024 · 0 comments
Closed

Move knitr::imgur_upload() to this package #83

yihui opened this issue Feb 8, 2024 · 0 comments

Comments

@yihui
Copy link
Owner

yihui commented Feb 8, 2024

so that packages using imgur_upload() don't have to depend on knitr.

The dependency on the R package curl could also be removed if the command curl exists.

BTW, imgur.com is blocked in certain countries. I'm not sure if there are other similar image hosting services. The one below doesn't really work:

https://freeimage.host/page/api

upload_freeimage = function(file, curl = Sys.which('curl')) {
  api = 'https://freeimage.host/api/1/upload/'
  key = '6d207e02198a847aa98d0a2a901485a5'
  # use the curl package if the curl command is not found
  if (curl == '') {
    h = curl::new_handle()
    curl::handle_setopt(h, customrequest = 'POST')
    curl::handle_setform(h, key = key, source = curl::form_file(file))
    res = rawToChar(curl::curl_fetch_memory(api, h)$content)
    return(res)
  }
  system2(c('curl', shQuote(c(
    '--form', paste0('key=', key), '--form', paste0('source=@', file), api
  ))))
}
@yihui yihui changed the title Move knitr::imgur_upload() to this package Move knitr::imgur_upload() to this package Feb 8, 2024
@yihui yihui closed this as completed in 95158cc Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant