gopaste
a rewrite of rustypaste. why? rustypaste is really complicated. for starters, it's written in an unmaintainable language.
there are core issues with the design as well
- files are retreived thru globbing, instead of direct key reference. this opens a giant can of worms that frankly i dont want to deal with
- the special features are hard coded directories/code paths, which makes working with the code annoying.
so we make a few small changes that make the app simpler to work with.
- subdirectories are split into /bucket/ instead of /
- file metadata is used to determine things like oneshot, expiration, etc.
- file metadata can either be read from the bucket configuration, or xattrs.
of course, this means that file expiration won't work on windows, and other filesystems that dont support xattrs.
that said, this isn't neccesarily true forever. I may implement file expiration using file created time attribute, which would enable file expiration
currently missing features:
- auto-deletion background job (i dont even use expiring files, so this is not very useful to me yet)
- storage deduplicate (i think this should be implemented via content-addressable storage implementation, which i dont care to do right now)
mostly im making this for myself, so features that i don't use or care about are not a very high priority.
basic usage
you can upload a file, and also make the file a oneshot, with commands such as
curl -F 'file=@filename' localhost:3000
curl -F 'oneshot=@filename' localhost:3000
you can also shorten a url, or make a oneshot, just like rustypaste, with something like
curl -F 'url=https:/google.com' localhost:3000
curl -F 'oneshot_url=https:/google.com' localhost:3000
special features
buckets
you use a specific bucket to store your files, like
curl -F 'file=@filename;headers="bucket: mybucket"' localhost:3000
bucket files are accessed via <root>/<bucket>/<file>
url, oneshot, and oneshot_url are special buckets
you can send custom metadata for your fileupload using multipart headers
in the previous section, things like url
, and oneshot
work through forcing specific metadata for any read/write to specific buckets
there is also special code that maps special form fields to specific bucket names, so you dont need to use headers for those special buckets.
in the future, i might to allow the user to attach custom metadata settings their own buckets.
oneshot
you can make any file in any bucket(even urls) oneshots
curl -F 'file=@filename;headers="oneshot: true"' localhost:3000
expiration
the config allows you to configure a default expiration time, which allows you to set a default expiry period for all uploads
entries will be expired on read.
TODO: enable automatic config sweeping (this feature is in config, but not implemented)
you can also set a custom expiration using
curl -F 'file=@filename;headers="expires: 60m"' localhost:3000
this is parsed with time.ParseDuration
you can also set a custom expirationAt using
curl -F 'file=@filename;headers="expiresat: 2025-10-04"' localhost:3000
this expiresAt is parsed with https://github.com/markusmobius/go-dateparser
classes
currently there is only one special class, the redirect class
if this class is set, then we will parse the content of the body as an url, and if it is a valid one, use it for a redirect
this is what the url
and oneshot_url
buckets use underneath
curl -F 'file="http://google.com";headers="class: redirect"' localhost:3000
mime type
you can set a custom content-type when the file is served using
curl -F 'file=@filename;headers="mime-type: image/png"' localhost:3000