diff options
author | clsr <clsr@clsr.net> | 2016-11-15 16:57:51 +0100 |
---|---|---|
committer | clsr <clsr@clsr.net> | 2016-11-15 19:28:55 +0100 |
commit | d3536e6741351fb13a9f6a327637bc2a4619fea4 (patch) | |
tree | f9cf707ed2b3daf6bea2d7a07f0c1ce9efbe5c23 /api.go | |
parent | 1e55e61786eaedd59c067f4306fb8427dc92ef52 (diff) | |
download | gomf-d3536e6741351fb13a9f6a327637bc2a4619fea4.tar.gz gomf-d3536e6741351fb13a9f6a327637bc2a4619fea4.zip |
Move storage to its own packagev0.5.0
Diffstat (limited to 'api.go')
-rw-r--r-- | api.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -6,6 +6,7 @@ import ( "encoding/hex" "encoding/json" "fmt" + "git.clsr.net/gomf/storage" "io" "mime" "net/http" @@ -17,9 +18,9 @@ import ( ) func handleFile(w http.ResponseWriter, r *http.Request) { - f, hash, size, modtime, err := storage.Get(strings.TrimLeft(r.URL.Path, "/")) + f, hash, size, modtime, err := uploads.Get(strings.TrimLeft(r.URL.Path, "/")) if err != nil { - if _, ok := err.(ErrNotFound); ok { + if _, ok := err.(storage.ErrNotFound); ok { http.Error(w, err.Error(), http.StatusNotFound) } else { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -94,13 +95,13 @@ func handleUpload(w http.ResponseWriter, r *http.Request) { continue } - id, hash, size, err := storage.New(part, part.FileName()) + id, hash, size, err := uploads.New(part, part.FileName()) if err != nil { resp.ErrorCode = http.StatusInternalServerError resp.Description = err.Error() - if _, ok := err.(ErrTooLarge); ok { + if _, ok := err.(storage.ErrTooLarge); ok { resp.ErrorCode = http.StatusRequestEntityTooLarge - } else if _, ok := err.(ErrForbidden); ok { + } else if _, ok := err.(storage.ErrForbidden); ok { resp.ErrorCode = http.StatusForbidden } break |