summaryrefslogtreecommitdiff
path: root/app/app.go
diff options
context:
space:
mode:
authorHeinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>2022-11-25 02:48:06 +0000
committerJames Mills <james@mills.io>2022-11-25 02:48:06 +0000
commit0a793f7d3fed115cdd242371490009db340deb00 (patch)
tree38b38ca038bc468be165673c49a1ecb3937f77ed /app/app.go
parent7a4ef5b6dfe804213d5cc1563f17deeb10e25455 (diff)
feat: Make upload path selectable (#39)
This works for me, but for a more public site, I think I'll also add a boolean attribute named "upload_allowed" and "writable" to Config.Library.. Something to allow you to configure which directories can receive new uploads, and which directories we consider writable for other purposes (like editing meta data in yml, creating new thumbnails, ...) Co-authored-by: Heinrich Langos <gumbo2000@noreply@mills.io> Reviewed-on: https://git.mills.io/prologic/tube/pulls/39 Co-authored-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io> Co-committed-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>
Diffstat (limited to 'app/app.go')
-rw-r--r--app/app.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/app/app.go b/app/app.go
index 37114b2..ae9244c 100644
--- a/app/app.go
+++ b/app/app.go
@@ -236,15 +236,12 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
title := r.FormValue("video_title")
description := r.FormValue("video_description")
-
- // TODO: Make collection user selectable from drop-down in Form
- // XXX: Assume we can put uploaded videos into the first collection (sorted) we find
- keys := make([]string, 0, len(a.Library.Paths))
- for k := range a.Library.Paths {
- keys = append(keys, k)
+ if _, exists := a.Library.Paths[r.FormValue("target_library_path")]; !exists {
+ err := fmt.Errorf("uploading to invalid library path: %s", r.FormValue("target_library_path"))
+ log.Error(err)
+ return
}
- sort.Strings(keys)
- collection := keys[0]
+ targetLibraryPath := r.FormValue("target_library_path")
uf, err := ioutil.TempFile(
a.Config.Server.UploadPath,
@@ -278,7 +275,7 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
}
vf := filepath.Join(
- a.Library.Paths[collection].Path,
+ a.Library.Paths[targetLibraryPath].Path,
fmt.Sprintf("%s.mp4", shortuuid.New()),
)
thumbFn1 := fmt.Sprintf("%s.jpg", strings.TrimSuffix(tf.Name(), filepath.Ext(tf.Name())))