2

I need create a file viewer in html, because html can open only txt. Thing like I need - raw githubusercontent. How it works?

KOT4N11
  • 31
  • 2
  • You will need to be more specific about what type of files you are using, how exactly you want them to appear, and what server-side language(s) are available to you. – kmoser Jun 05 '22 at 17:34

1 Answers1

0

If your file viewer can use curl, you can use gh api to get the content URL of a file, and download it, as seen here:

API_URL=https://api.github.com/repos/owner/repo/contents/path/file.ext
curl $(gh api $API_URL --jq .download_url) -o file.ext

That would simulate what raw.githubusercontent.com does.
And not just for .txt files.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250