1
1
Fork
You've already forked copesour
0
Media upload relay for Mastodon
  • JavaScript 96.4%
  • CSS 1.8%
  • HTML 1.8%
2026年01月25日 17:27:26 -08:00
src use react linting 2025年07月12日 20:04:01 -07:00
.env.template implement uploads 2024年09月06日 17:14:11 -07:00
.env.test tests for too-big file and incompatible draft ver 2024年12月09日 16:38:39 -08:00
.gitignore initial commit 2024年09月03日 00:40:51 -07:00
COPYING initial commit 2024年09月03日 00:40:51 -07:00
eslint.config.mjs use react linting 2025年07月12日 20:04:01 -07:00
package-lock.json upgrade some deps 2026年01月25日 17:27:26 -08:00
package.json use react linting 2025年07月12日 20:04:01 -07:00
README.md README typo 2024年11月24日 16:16:27 -08:00
vite.config.js fix vitest cache dir 2025年06月06日 21:09:30 -07:00

Copesour, media relay for Mastodon

You may have noticed: uploading photos to Mastodon from a mobile connection can be difficult, when you have less than perfect signal! And uploading videos? Forget about it! You're going to be watching that upload fail, and pressing Retry, over and over, and your toot is never going to post.

This happened to me many times, and I thought:

Why don't Mastodon apps simply resume the partially completed upload? I know! I'll make a Mastodon app that does that.

Oh, you sweet summer child, me. It turns out, while you can resume downloads, there is no standard way to resume uploads in HTTP! Every mobile app that reliably uploads photos and videos has implemented their own ad-hoc API to do this! Mastodon, meanwhile, hasn't: its API requires all media to be uploaded in one go.

While I filed a Mastodon issue asking for resumable uploads, I don't expect that to get prioritized anytime soon, and I'm not even sure it would get merged if I wrote the PR myself. So in the meantime, here's my hack solution! Copesour is a media relay that you can host in the cloud, or on a server in your closet, or whatever (I use a VPS). You log into the media relay through Mastodon, attach your photos or video, write your status, and post, and the uploads from your browser to the relay do support resuming (using a rough implementation of the draft standard that is finally being written, Resumable Uploads for HTTP, although this is just an implementation detail). Once they're uploaded to the relay, the relay uploads them to your Mastodon instance and posts for you.

Setup

Copesour requires SQLite 3 and Node.js, probably 20+, 18 might or might not work.

  1. npm install
  2. Copy .env.template to .env.development.local (for development) or .env.production.local (for production) and fill in/modify the relevant values
  3. To try it locally: npm run dev
  4. To deploy, on your server: npm start and consider redirecting the standard output/error to somewhere you'd like logs to go, such as npm start >>logs.txt 2>&1

This is early software with many limitations and bugs. I'm running an relay for just myself. I don't recommend letting anyone you don't trust use your relay. I reverse proxy mine from Nginx (for the HTTPS). If you do that, you may have to increase Nginx's client_max_body_size for Copesour to avoid 413 errors.