Home About Me

A Small Go Uploader for GitHub and Gitee Image Hosting

repo-image-hosting is a compact Go/Gin utility that turns a GitHub or Gitee repository into a personal image host. Gitee is a practical choice when you want something free, stable, and fast to reach from mainland China. GitHub is supported as well, with jsdelivr used for acceleration.

Web interface Upload demo

What it does

  • Uses GitHub or Gitee as the storage backend for images.
  • Serves GitHub-hosted images through jsdelivr.
  • Handles Gitee images larger than 1 MB for display, provided Gitee Pages has been enabled and deployed manually.
  • Starts from a single binary, works across platforms, and has no runtime dependency beyond that binary.
  • Provides a browser-based interface. It is fairly plain, but usable.
  • Uploads multiple images at once in jpeg, jpg, gif, and png formats.
  • Lets you copy image URLs and delete images.

Running it

Download the release binary and start it. The available options are:

<table> <thead> <tr> <th>Option</th> <th>Meaning</th> <th>Default</th> </tr> </thead> <tbody> <tr> <td>owner</td> <td>Namespace that owns the repository (user, organization, or enterprise path)</td> <td>hezhizheng</td> </tr> <tr> <td>path</td> <td>File path inside the repository</td> <td>image-hosting</td> </tr> <tr> <td>platform</td> <td>Platform name: gitee or github</td> <td>github</td> </tr> <tr> <td>port</td> <td>Local listening port</td> <td>2047</td> </tr> <tr> <td>repo</td> <td>Repository path</td> <td>static-image-hosting</td> </tr> <tr> <td>token</td> <td>Gitee/GitHub user authorization token</td> <td>—</td> </tr> </tbody> </table>

A complete startup command looks like this:

./repo-image-hosting_windows_amd64.exe -platform github -owner hezhizheng -repo static-image-hosting -path image-hosting -token xxxtoken -port 2047

Replace the values with your own. Create a Gitee token at https://gitee.com/profile/personal_access_tokens/new and a GitHub token at https://github.com/settings/tokens/new.

Building from source

// Install go-bindata before compiling; see https://blog.hi917.com/detail/87.html
// Compile static assets (run this every time static files change)
go-bindata -o=bindata/bindata.go -pkg=bindata ./static/... ./views/...

// Cross-platform builds
gox -osarch="windows/amd64" -ldflags "-s -w"

gox -osarch="darwin/amd64" -ldflags "-s -w"

gox -osarch="linux/amd64" -ldflags "-s -w"

Gitee images over 1 MB

Gitee limits access to images larger than 1 MB. There are two ways to deal with it:

  • Compress the image with a third-party tool before uploading. compressjpeg is a recommended option.
  • Enable Gitee Pages. For non-paid users, the Pages service has to be deployed manually after an image is uploaded. The program will then use the Pages domain when displaying the image.

For a small uploader that you run locally, the workflow stays simple: launch the binary, open the web page, upload, and grab the URL.