-
Notifications
You must be signed in to change notification settings - Fork 13
/
uploader.go
79 lines (65 loc) · 2.03 KB
/
uploader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package uploader
import (
"net/http"
tusd "github.com/tus/tusd/pkg/handler"
)
type Uploader interface {
PostFile(w http.ResponseWriter, r *http.Request)
PatchFile(w http.ResponseWriter, r *http.Request)
DelFile(w http.ResponseWriter, r *http.Request)
GetFile(w http.ResponseWriter, r *http.Request)
HeadFile(w http.ResponseWriter, r *http.Request)
Middleware(h http.Handler) http.Handler
SupportedExtensions() string
Metrics() tusd.Metrics
GetCreatedUploadsChan() chan tusd.HookEvent
GetCompletedUploadsChan() chan tusd.HookEvent
GetTerminatedUploadsChan() chan tusd.HookEvent
GetUploadProgressChan() chan tusd.HookEvent
}
type TUSDUploader struct {
handler *tusd.UnroutedHandler
}
func NewTUSDUploader(c tusd.Config) Uploader {
uploader, err := tusd.NewUnroutedHandler(c)
if err != nil {
panic(err)
}
return &TUSDUploader{handler: uploader}
}
func (u *TUSDUploader) PostFile(w http.ResponseWriter, r *http.Request) {
u.handler.PostFile(w, r)
}
func (u *TUSDUploader) PatchFile(w http.ResponseWriter, r *http.Request) {
u.handler.PatchFile(w, r)
}
func (u *TUSDUploader) DelFile(w http.ResponseWriter, r *http.Request) {
u.handler.DelFile(w, r)
}
func (u *TUSDUploader) GetFile(w http.ResponseWriter, r *http.Request) {
u.handler.GetFile(w, r)
}
func (u *TUSDUploader) HeadFile(w http.ResponseWriter, r *http.Request) {
u.handler.HeadFile(w, r)
}
func (u *TUSDUploader) Middleware(h http.Handler) http.Handler {
return u.handler.Middleware(h)
}
func (u *TUSDUploader) SupportedExtensions() string {
return u.handler.SupportedExtensions()
}
func (u *TUSDUploader) Metrics() tusd.Metrics {
return u.handler.Metrics
}
func (u *TUSDUploader) GetCreatedUploadsChan() chan tusd.HookEvent {
return u.handler.CreatedUploads
}
func (u *TUSDUploader) GetCompletedUploadsChan() chan tusd.HookEvent {
return u.handler.CompleteUploads
}
func (u *TUSDUploader) GetTerminatedUploadsChan() chan tusd.HookEvent {
return u.handler.TerminatedUploads
}
func (u *TUSDUploader) GetUploadProgressChan() chan tusd.HookEvent {
return u.handler.UploadProgress
}