Add admin interface
This commit is contained in:
@@ -101,7 +101,16 @@ func (s *Server) uploadMultipart(w http.ResponseWriter, r *http.Request, boundar
|
||||
return
|
||||
}
|
||||
mr := multipart.NewReader(r.Body, boundary)
|
||||
req := uploadRequest{token: bearer(r)}
|
||||
|
||||
// Headers seed the request even here, so that a caller mixing the two
|
||||
// shapes — curl -F with a Vanity header, say — is not silently given a
|
||||
// UUID instead of the name they asked for. A non-empty form field of the
|
||||
// same meaning overrides them.
|
||||
req := uploadRequest{
|
||||
token: bearer(r),
|
||||
vanity: strings.TrimSpace(r.Header.Get("Vanity")),
|
||||
expiry: strings.TrimSpace(r.Header.Get("Expiry")),
|
||||
}
|
||||
req.explicit = req.token != ""
|
||||
|
||||
for n := 0; ; n++ {
|
||||
@@ -147,9 +156,13 @@ func (s *Server) uploadMultipart(w http.ResponseWriter, r *http.Request, boundar
|
||||
case "remember":
|
||||
req.remember = true
|
||||
case "vanity":
|
||||
req.vanity = strings.TrimSpace(value)
|
||||
if v := strings.TrimSpace(value); v != "" {
|
||||
req.vanity = v
|
||||
}
|
||||
case "expiry":
|
||||
req.expiry = strings.TrimSpace(value)
|
||||
if v := strings.TrimSpace(value); v != "" {
|
||||
req.expiry = v
|
||||
}
|
||||
case "filename":
|
||||
req.filename = value
|
||||
}
|
||||
@@ -428,7 +441,7 @@ func (s *Server) respondUploaded(w http.ResponseWriter, r *http.Request, m *stor
|
||||
s.render(w, http.StatusOK, "result.html", objectPage{
|
||||
// The script is loaded here only to enable the copy buttons, which stay
|
||||
// hidden without it rather than sitting there dead.
|
||||
page: s.page("Uploaded", true),
|
||||
page: s.page(r, "Uploaded", true),
|
||||
Meta: m,
|
||||
Size: config.FormatSize(m.Size),
|
||||
Expires: describeExpiry(m.Expires, s.now()),
|
||||
|
||||
Reference in New Issue
Block a user