- JavaScript 96.4%
- CSS 1.8%
- HTML 1.8%
| src | use react linting | |
| .env.template | implement uploads | |
| .env.test | tests for too-big file and incompatible draft ver | |
| .gitignore | initial commit | |
| COPYING | initial commit | |
| eslint.config.mjs | use react linting | |
| package-lock.json | upgrade some deps | |
| package.json | use react linting | |
| README.md | README typo | |
| vite.config.js | fix vitest cache dir | |
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.
npm install- Copy
.env.templateto.env.development.local(for development) or.env.production.local(for production) and fill in/modify the relevant values - To try it locally:
npm run dev - To deploy, on your server:
npm startand consider redirecting the standard output/error to somewhere you'd like logs to go, such asnpm 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.