Comments and fixed status code

This commit is contained in:
Felix Geisendörfer 2013-05-06 15:08:34 +02:00
parent 8b1a251f6f
commit d490f50d45
2 changed files with 9 additions and 1 deletions

View File

@ -31,6 +31,8 @@ func (s *DataStore) CreateFile(id string, size int64, meta map[string]string) er
} }
defer file.Close() defer file.Close()
// @TODO Refactor DataStore to support meta argument properly. Needs to be
// defined in tus protocol first.
entry := logEntry{Meta: &metaEntry{ entry := logEntry{Meta: &metaEntry{
Size: size, Size: size,
ContentType: "", ContentType: "",

View File

@ -66,7 +66,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
// example relPath results: "/", "/f81d4fae7dec11d0a765-00a0c91e6bf6", etc. // example relPath results: "/", "/f81d4fae7dec11d0a76500a0c91e6bf6", etc.
relPath := absPath[len(h.config.BasePath)-1:] relPath := absPath[len(h.config.BasePath)-1:]
// file creation request // file creation request
@ -98,11 +98,17 @@ func (h *Handler) createFile(w http.ResponseWriter, r *http.Request) {
return return
} }
// @TODO: What happens if Final-Length is <= 0
// @TODO: Provide meta data
// @TODO: Make max finalLength configurable, reply with error if exceeded.
// This should go into the protocol as well.
if err := h.store.CreateFile(id, finalLength, nil); err != nil { if err := h.store.CreateFile(id, finalLength, nil); err != nil {
h.err(err, w, http.StatusInternalServerError) h.err(err, w, http.StatusInternalServerError)
return return
} }
w.WriteHeader(http.StatusCreated)
w.Header().Set("Location", h.absUrl(r, "/"+id)) w.Header().Set("Location", h.absUrl(r, "/"+id))
} }