(cache UploadCache)
| 123 | } |
| 124 | |
| 125 | func 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 | |
| 156 | func tusPatchHandler(cache UploadCache) handleFunc { |
| 157 | return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { |
no test coverage detected