MCPcopy
hub / github.com/filebrowser/filebrowser / tusHeadHandler

Function tusHeadHandler

http/tus_handlers.go:125–154  ·  view source on GitHub ↗
(cache UploadCache)

Source from the content-addressed store, hash-verified

123}
124
125func tusHeadHandler(cache UploadCache) handleFunc {
126 return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
127 w.Header().Set("Cache-Control", "no-store")
128 if !d.user.Perm.Create || !d.Check(r.URL.Path) {
129 return http.StatusForbidden, nil
130 }
131
132 file, err := files.NewFileInfo(&files.FileOptions{
133 Fs: d.user.Fs,
134 Path: r.URL.Path,
135 Modify: d.user.Perm.Modify,
136 Expand: false,
137 ReadHeader: d.server.TypeDetectionByHeader,
138 Checker: d,
139 })
140 if err != nil {
141 return errToStatus(err), err
142 }
143
144 uploadLength, err := cache.GetLength(file.RealPath())
145 if err != nil {
146 return http.StatusNotFound, err
147 }
148
149 w.Header().Set("Upload-Offset", strconv.FormatInt(file.Size, 10))
150 w.Header().Set("Upload-Length", strconv.FormatInt(uploadLength, 10))
151
152 return http.StatusOK, nil
153 })
154}
155
156func tusPatchHandler(cache UploadCache) handleFunc {
157 return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {

Callers 1

NewHandlerFunction · 0.85

Calls 6

RealPathMethod · 0.95
NewFileInfoFunction · 0.92
withUserFunction · 0.85
errToStatusFunction · 0.85
CheckMethod · 0.65
GetLengthMethod · 0.65

Tested by

no test coverage detected