summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Angel Ajo <majopela@redhat.com>2019-12-30 00:05:39 +0100
committerMiguel Angel Ajo <majopela@redhat.com>2019-12-30 00:49:00 +0100
commit2469ec062724f39d594f84d1c62362da01b9a644 (patch)
treec4df3381145e3bfaf01ac02f438b24a1a352a5f0
parent10d7c93dd0103a46b22100c9b681e270bfd3c3a0 (diff)
Also handle uploads
-rw-r--r--system/admin/upload/upload.go7
1 files changed, 1 insertions, 6 deletions
diff --git a/system/admin/upload/upload.go b/system/admin/upload/upload.go
index fd29796..e19c3af 100644
--- a/system/admin/upload/upload.go
+++ b/system/admin/upload/upload.go
@@ -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 {
@@ -57,7 +52,7 @@ func StoreFiles(req *http.Request) (map[string]string, error) {
urlPathPrefix := "api"
uploadDirName := "uploads"
- 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