Created
June 20, 2016 09:54
-
-
Save kana-sama/cbcb39decb96e185411edb5987cee247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package handlers | |
// import ( | |
// "io" | |
// "net/http" | |
// "os" | |
// "path/filepath" | |
// "github.com/satori/go.uuid" | |
// . "github.com/the-varlog/revote/config" | |
// . "github.com/the-varlog/revote/middlewares" | |
// . "github.com/the-varlog/revote/models" | |
// "github.com/the-varlog/revote/responses" | |
// ) | |
// func ImageUpload() http.Handler { | |
// return AccessLevelChecker(EditorAccessLevel, http.HandlerFunc( | |
// func(w http.ResponseWriter, r *http.Request) { | |
// src, _, err := r.FormFile("data") | |
// if err != nil { | |
// responses.BadRequest().Write(w) | |
// return | |
// } | |
// defer src.Close() | |
// if err := os.MkdirAll(Config.ImagesStore, 0666); err != nil { | |
// responses.InternalServerError().Write(w) | |
// return | |
// } | |
// filename := uuid.NewV4().String() | |
// fullPath := filepath.Join(Config.ImagesStore, filename) | |
// dest, err := os.OpenFile(fullPath, os.O_WRONLY|os.O_CREATE, 0666) | |
// if err != nil { | |
// responses.InternalServerError().Write(w) | |
// return | |
// } | |
// defer dest.Close() | |
// if _, err := io.Copy(dest, src); err != nil { | |
// responses.InternalServerError().Write(w) | |
// return | |
// } | |
// responses.OK(filename).Write(w) | |
// }, | |
// )) | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment