Skip to content

Commit

Permalink
Also handle uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
mangelajo committed Dec 29, 2019
1 parent 10d7c93 commit 12ebea0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions system/admin/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ func StoreFiles(req *http.Request) (map[string]string, error) {
req.Form.Set("timestamp", ts)

// get or create upload directory to save files from request
pwd, err := os.Getwd()
if err != nil {
err := fmt.Errorf("Failed to locate current directory: %s", err)
return nil, err
}

i, err := strconv.ParseInt(ts, 10, 64)
if err != nil {
Expand All @@ -55,9 +50,9 @@ func StoreFiles(req *http.Request) (map[string]string, error) {
tm := time.Unix(int64(i/1000), int64(i%1000))

urlPathPrefix := "api"
uploadDirName := "uploads"
uploadDirName := "upload"

uploadDir := filepath.Join(pwd, uploadDirName, fmt.Sprintf("%d", tm.Year()), fmt.Sprintf("%02d", tm.Month()))
uploadDir := filepath.Join(cfg.UploadDir(), fmt.Sprintf("%d", tm.Year()), fmt.Sprintf("%02d", tm.Month()))
err = os.MkdirAll(uploadDir, os.ModeDir|os.ModePerm)
if err != nil {
return nil, err
Expand Down

0 comments on commit 12ebea0

Please sign in to comment.