Git Product home page Git Product logo

goupfile's Introduction

Goupfile Build status Go Report Card

Goupfile is a file sharing service.

Features

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

HTTP API

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

Configuration

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.

Proxying though nginx

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;
	}
}

Developing

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.

Docker

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

CSS

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.

Database notes

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.

Screenshots

Goupfile home page

Goupfile file view page

License

MIT

goupfile's People

Contributors

johnjago avatar

Stargazers

Hugh L. avatar  avatar Riley Snyder avatar  avatar Catalin avatar Adrian avatar

Watchers

Neustradamus avatar James Cloos avatar Adrian avatar  avatar  avatar  avatar

goupfile's Issues

Create basic homepage that links to docs

No functionality through this just yet. This page will simply describe Goupfile, link to the documentation, and explain how to use it.

It will be served whenever someone connects over HTTP or HTTPS to goupfile.com.

Explore using a smaller base Docker image

The current Dockerfile uses the golang:buster image which is Debian and comes with a lot of stuff that this application doesn't need. golang:alpine would be better, but additional steps will have to be added to install Git (used for the go get command) and possibly some other tools.

This will speed up pulling/pushing the container in the future.

Expand ID system

There are currently 36^6 = 2,176,782,336 possible unique IDs for files.

There could be an option to use memorable IDs like DonkeySneezeQuick, which are a pattern of dictionary words concatenated together.

Prevent ID collisions

Although unlikely, it's possible that an ID could be generated that is the same as one that already exists, causing someone else's file to be overwritten. The code should check if such an ID already exists before assigning it to a file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.