diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-29 17:56:46 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-29 17:56:46 -0700 |
commit | c930db63601095ce386413b3eb764b71ee71fe2c (patch) | |
tree | 0142977cd022caa62ca487010f0e51a3dd2272de | |
parent | ed4c47babef56f18df0a5b393b0c0fe79e659105 (diff) |
renaming and moving File upload logic into own package
-rw-r--r-- | system/admin/handlers.go | 5 | ||||
-rw-r--r-- | system/admin/upload/upload.go (renamed from system/admin/upload.go) | 6 | ||||
-rw-r--r-- | system/api/external.go | 4 |
3 files changed, 8 insertions, 7 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go index ce07c4c..6f23683 100644 --- a/system/admin/handlers.go +++ b/system/admin/handlers.go @@ -14,6 +14,7 @@ import ( "github.com/bosssauce/ponzu/management/editor" "github.com/bosssauce/ponzu/management/manager" "github.com/bosssauce/ponzu/system/admin/config" + "github.com/bosssauce/ponzu/system/admin/upload" "github.com/bosssauce/ponzu/system/admin/user" "github.com/bosssauce/ponzu/system/api" "github.com/bosssauce/ponzu/system/db" @@ -869,7 +870,7 @@ func editHandler(res http.ResponseWriter, req *http.Request) { req.PostForm.Set("updated", ts) } - urlPaths, err := StoreFileUploads(req) + urlPaths, err := upload.StoreFiles(req) if err != nil { log.Println(err) res.WriteHeader(http.StatusInternalServerError) @@ -971,7 +972,7 @@ func editUploadHandler(res http.ResponseWriter, req *http.Request) { return } - urlPaths, err := StoreFileUploads(req) + urlPaths, err := upload.StoreFiles(req) if err != nil { log.Println("Couldn't store file uploads.", err) res.WriteHeader(http.StatusInternalServerError) diff --git a/system/admin/upload.go b/system/admin/upload/upload.go index 3f61765..169bffe 100644 --- a/system/admin/upload.go +++ b/system/admin/upload/upload.go @@ -1,4 +1,4 @@ -package admin +package upload import ( "fmt" @@ -10,8 +10,8 @@ import ( "time" ) -// StoreFileUploads stores file uploads at paths like /YYYY/MM/filename.ext -func StoreFileUploads(req *http.Request) (map[string]string, error) { +// StoreFiles stores file uploads at paths like /YYYY/MM/filename.ext +func StoreFiles(req *http.Request) (map[string]string, error) { err := req.ParseMultipartForm(1024 * 1024 * 4) // maxMemory 4MB if err != nil { return nil, fmt.Errorf("%s", err) diff --git a/system/api/external.go b/system/api/external.go index 1c69afb..52240d5 100644 --- a/system/api/external.go +++ b/system/api/external.go @@ -8,7 +8,7 @@ import ( "time" "github.com/bosssauce/ponzu/content" - "github.com/bosssauce/ponzu/system/admin" + "github.com/bosssauce/ponzu/system/admin/upload" "github.com/bosssauce/ponzu/system/db" ) @@ -68,7 +68,7 @@ func externalPostsHandler(res http.ResponseWriter, req *http.Request) { req.PostForm.Set("updated", ts) req.PostForm.Set("id", ts) - urlPaths, err := admin.storeFileUploads(req) + urlPaths, err := upload.StoreFiles(req) if err != nil { log.Println(err) res.WriteHeader(http.StatusInternalServerError) |