Goupfile is a file sharing service.
What makes this one different?
- Share multiple files under one URL
- URLs are short, memorable, and don't have ambiguous characters
- QR codes so that you can upload files on one device and easily access them on another
- Upload from any browser at goupfile.johnjago.com
- There's a CLI tool for uploading files from the terminal
- No dependencies: it uses a SQLite database and saves files to the local filesystem
- Easy to deploy: just download a single binary and run
- Lightweight: runs on any machine in the cloud
GET / Show the home page and upload/download from there
POST /upload Upload a file (use multipart/form-data)
GET /d/{id} Download a file
GET /v/{id} View file download page
In main.go, there is a block where you can configure Goupfile. For example, you can change the directory where uploaded files are stored.
const (
port = ":8090"
staticDir = "./public"
driver = "sqlite3"
dataSource = "sqlite_db"
// This is only for generating the QR code from a URL since when it's
// running behind nginx, for example, it doesn't know what the outside
// facing hostname is unless we tell it. A real setup might look like:
// this program running on localhost:8090, but nginx accepts requests at
// https://file.com, in which case the below value would be https://file.com
publicHost = "https://goupfile.johnjago.com"
)
These probably should be moved to environment variables.
It's common to proxy requests through a server like nginx. This allows you to simply run Goupfile on something like http://localhost:8090 and have nginx take care of the public facing TLS, hostname, and other configuration.
One configuration that's useful to adjust for an application like Goupfile is
client_max_body_size
which allows you to specify a limit on how large an
uploaded file can be.
server {
server_name goupfile.johnjago.com;
listen *:80;
listen [::]:80;
return 301 https://goupfile.johnjago.com$request_uri;
}
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
ssl_certificate /path/to/cert;
ssl_certificate_key /path/to/private/key;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
client_max_body_size 10M;
location / {
proxy_pass http://localhost:8090;
}
}
Clone the repository:
git clone [email protected]:goupfile/server.git
Then run the server from the root of the project:
go run -v ./...
or
make run
To automatically build and run the project every time a file changes, you can use a tool like gow.
Using Docker, you can build and run Goupfile without having Go installed and
without gcc (since mattn/go-sqlite3
is a cgo package and relies on gcc).
If you don't already have it, install Docker Engine.
git clone [email protected]:goupfile/server.git
cd server
npm install && npm run css-prod
docker build . -t goupfile
docker container run -p 8090:8090 goupfile
This project uses Tailwind CSS. The following will
create a CSS file with all Tailwind classes, which is helpful in development
because you can use any Tailwind CSS utility. The file produced by css-dev
is
over 3 MB, so don't use it in production!
npm install
npm run css-dev
For a production build,
npm run css-prod
This will produce a CSS file with only the classes you used in the HTML.
Goupfile currently uses SQLite as its database. SQLite has an overview of use
cases where it works well, and right now
it's a good choice for Goupfile. However, with many concurrent writes or large
numbers of files that don't fit on a single VM's disk, there may be issues. In
that case, it's almost trivial to swap out SQLite for PostgreSQL or MariaDB.
Just change the driver
and dataSource
in main.go.
MIT