a1141b836f
commit 0203e5c57f397865fd5a95b7f91f5f27fd306431 Author: Marius <maerious@gmail.com> Date: Sat Jan 9 20:39:46 2016 +0100 Update dependencies commit be5b2b8f62b4644fd9c52a838fe68d98b4eae8e4 Author: Marius <maerious@gmail.com> Date: Sat Jan 9 19:17:32 2016 +0100 Pull dependencies from vendor/ in /home/marius/workspace/go for Go < 1.5 commit e631bbcc59e4c9e5e928b172b4c6aab6eb71274d Author: Marius <maerious@gmail.com> Date: Sat Jan 9 19:15:20 2016 +0100 Vendor dependencies |
||
---|---|---|
cmd/tusd | ||
filestore | ||
limitedstore | ||
memorylocker | ||
s3store | ||
uid | ||
vendor/github.com | ||
.gitignore | ||
.gitmodules | ||
.travis.yml | ||
LICENSE.txt | ||
README.md | ||
appveyor.yml | ||
concat_test.go | ||
cors_test.go | ||
datastore.go | ||
get_test.go | ||
handler.go | ||
handler_test.go | ||
head_test.go | ||
options_test.go | ||
patch_test.go | ||
post_test.go | ||
terminate_test.go | ||
unrouted_handler.go |
README.md
tusd
tusd is the official reference implementation of the tus resumable upload protocol. The protocol specifies a flexible method to upload files to remote servers using HTTP. The special feature is the ability to pause and resume uploads at any moment allowing to continue seamlessly after e.g. network interruptions.
Protocol version: 1.0.0
Getting started
Requirements:
- Go (1.2 or newer)
Running tusd from source:
Clone the git repository and cd
into it.
git clone git@github.com:tus/tusd.git
cd tusd
Now you can run tusd:
go run cmd/tusd/main.go
Using tusd manually
Besides from running tusd using the provided binary, you can embed it into your own Golang program:
package main
import (
"github.com/tus/tusd"
"github.com/tus/tusd/filestore"
"net/http"
)
func main() {
// Create a new FileStore instance which is responsible for
// storing the uploaded file on disk in the specified directory.
// If you want to save them on a different medium, for example
// a remote FTP server, you can implement your own storage backend
// by implementing the tusd.DataStore interface.
store := filestore.FileStore{
Path: "./uploads",
}
// Create a new HTTP handler for the tusd server by providing
// a configuration object. The DataStore property must be set
// in order to allow the handler to function.
handler, err := tusd.NewHandler(tusd.Config{
BasePath: "files/",
DataStore: store,
})
if err != nil {
panic("Unable to create handler: %s", err)
}
// Right now, nothing has happened since we need to start the
// HTTP server on our own. In the end, tusd will listen on
// and accept request at http://localhost:8080/files
http.Handle("files/", http.StripPrefix("files/", handler))
err = http.ListenAndServe(":8080", nil)
if err != nil {
panic("Unable to listen: %s", err)
}
}
If you need to customize the GET and DELETE endpoints use
tusd.NewUnroutedHandler
instead of tusd.NewHandler
.
Implementing own storages
The tusd server is built to be as flexible as possible and to allow the use
of different upload storage mechanisms. By default the tusd binary includes
filestore
which will save every upload
to a specific directory on disk.
If you have different requirements, you can build your own storage backend
which will save the files to S3, a remote FTP server or similar. Doing so
is as simple as implementing the tusd.DataStore
interface and using the new struct in the configuration object.
Please consult the documentation about detailed information about the
required methods.
Running the testsuite
go test -v ./...
License
This project is licensed under the MIT license, see LICENSE.txt
.