parse new video in new go function
validate extension on server to allow only videos
This commit is contained in:
parent
156aaa7a71
commit
fd5542c528
@ -7,6 +7,7 @@ import (
|
||||
"openmediacenter/apiGo/database"
|
||||
"openmediacenter/apiGo/videoparser"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func addUploadHandler() {
|
||||
@ -21,8 +22,12 @@ func addUploadHandler() {
|
||||
|
||||
mr, err := req.MultipartReader()
|
||||
if err != nil {
|
||||
ctx.Errorf("incorrect request!")
|
||||
return
|
||||
}
|
||||
|
||||
videoparser.InitDeps(&mSettings)
|
||||
|
||||
//length := req.ContentLength
|
||||
for {
|
||||
part, err := mr.NextPart()
|
||||
@ -30,9 +35,11 @@ func addUploadHandler() {
|
||||
break
|
||||
}
|
||||
|
||||
//var read int64
|
||||
//var p float32
|
||||
// todo check where we want to place this file
|
||||
// todo allow more video formats than mp4
|
||||
// only allow valid extensions
|
||||
if filepath.Ext(part.FileName()) != ".mp4" {
|
||||
continue
|
||||
}
|
||||
vidpath := PathPrefix + mSettings.VideoPath + part.FileName()
|
||||
dst, err := os.OpenFile(vidpath, os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
@ -54,8 +61,7 @@ func addUploadHandler() {
|
||||
|
||||
if err == io.EOF {
|
||||
fmt.Printf("Finished uploading file %s\n", part.FileName())
|
||||
videoparser.InitDeps(&mSettings)
|
||||
videoparser.ProcessVideo(part.FileName())
|
||||
go videoparser.ProcessVideo(part.FileName())
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ server {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
|
||||
location ~* ^/(api/|token) {
|
||||
location ~* ^/(api) {
|
||||
client_max_body_size 10G;
|
||||
proxy_pass http://127.0.0.1:8081;
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ export const DropZone = (): JSX.Element => {
|
||||
const theme = GlobalInfos.getThemeStyle();
|
||||
|
||||
const uploadFile = (f: FileList): void => {
|
||||
let xhr = new XMLHttpRequest(); // create XMLHttpRequest
|
||||
let data = new FormData(); // create formData object
|
||||
const xhr = new XMLHttpRequest(); // create XMLHttpRequest
|
||||
const data = new FormData(); // create formData object
|
||||
|
||||
for (let i = 0; i < f.length; i++) {
|
||||
const file = f.item(i);
|
||||
@ -22,6 +22,8 @@ export const DropZone = (): JSX.Element => {
|
||||
|
||||
xhr.onload = function (): void {
|
||||
console.log(this.responseText); // whatever the server returns
|
||||
|
||||
setpercent(0);
|
||||
};
|
||||
|
||||
xhr.upload.onprogress = function (e): void {
|
||||
@ -70,7 +72,6 @@ export const DropZone = (): JSX.Element => {
|
||||
input.multiple = true;
|
||||
input.onchange = function (): void {
|
||||
if (input.files) {
|
||||
console.log(input.files);
|
||||
uploadFile(input.files);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user