usethis icon indicating copy to clipboard operation
usethis copied to clipboard

Make `use_github_file()` more general

Open jennybc opened this issue 2 years ago • 1 comments

As it stands, we've built-in the assumption that we're dealing with a plain text file, but I don't see why it should be limited to that.

jennybc avatar Mar 04 '23 00:03 jennybc

Currently text files are saved to a tempfile, then read with read_utf8() and written to the final destination with write_over(), presumably to ensure the file has utf8 enconding (and maybe normalize line endings?).

For non-text files, we should just copy the downloaded file to its final destination.

The github contents API (https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content) doesn't appear to give the MIME type of the file, so we need to figure it out ourselves. I am going to use mime::guess_mime_type() to get started, even though it adds a new dependency.

ateucher avatar Sep 19 '25 15:09 ateucher