summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/app.go15
-rw-r--r--static/upload.js2
-rw-r--r--templates/upload.html5
3 files changed, 13 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())))
diff --git a/static/upload.js b/static/upload.js
index f4da351..965f2ed 100644
--- a/static/upload.js
+++ b/static/upload.js
@@ -13,6 +13,7 @@ let file = null
const uploadForm = document.getElementById('upload-form')
const videoInput = document.getElementById('video-input')
+const targetLibraryPath = document.getElementById('target-library-path')
const videoTitle = document.getElementById('video-title')
const videoDescription = document.getElementById('video-description')
const uploadMessageLabel = document.getElementById('upload-message')
@@ -164,6 +165,7 @@ const startUploading = () => {
const formData = new FormData()
formData.append('video_file', file)
+ formData.append('target_library_path', targetLibraryPath.value)
formData.append('video_title', videoTitle.value)
formData.append('video_description', videoDescription.value)
const xhr = new XMLHttpRequest()
diff --git a/templates/upload.html b/templates/upload.html
index 54c2ccd..e188de6 100644
--- a/templates/upload.html
+++ b/templates/upload.html
@@ -9,6 +9,11 @@
<span>Click to browse or drop file here</span>
</div>
<div class="upload-details">
+ <select id="target-library-path" name="target-library-path">
+{{range $index, $item :=.Config.Library}}
+ <option value="{{$item.Path}}">{{$item.Path}}</option>
+{{end}}
+ </select>
<input id="video-title" type="text" placeholder="Optional title" />
<textarea id="video-description" rows="2" placeholder="Optional description"></textarea>
<div id="upload-file" class="upload-file">