|
|
package v1
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"opp/controllers"
|
|
|
"opp/protocol"
|
|
|
"opp/services/upload"
|
...
|
...
|
@@ -18,25 +19,27 @@ func (this *UploadController) Image() { |
|
|
var (
|
|
|
msg *protocol.ResponseMessage
|
|
|
err error
|
|
|
rsp *protocol.FileResponse = &protocol.FileResponse{}
|
|
|
)
|
|
|
defer func() {
|
|
|
this.Resp(msg)
|
|
|
}()
|
|
|
var request = &protocol.FileRequest{}
|
|
|
//if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{
|
|
|
// log.Error(err)
|
|
|
// msg = protocol.ReturnResponse(1)
|
|
|
// return
|
|
|
//}
|
|
|
//if b,m :=this.Valid(request);!b{
|
|
|
// msg = m
|
|
|
// return
|
|
|
//}
|
|
|
if request.Files, err = this.GetFiles("image"); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
for i := 1; i <= 9; i++ {
|
|
|
var tmp *protocol.FileResponse
|
|
|
key := fmt.Sprintf("%v%v", "image", i)
|
|
|
if request.Files, err = this.GetFiles(key); err != nil {
|
|
|
log.Error(key, err)
|
|
|
err = nil
|
|
|
break
|
|
|
}
|
|
|
if tmp, err = upload.Image(request); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp.Paths = append(rsp.Paths, tmp.Paths...)
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(upload.Image(request))
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
|
|
}
|
|
|
|
|
|
// Voice
|
...
|
...
|
@@ -45,25 +48,27 @@ func (this *UploadController) Voice() { |
|
|
var (
|
|
|
msg *protocol.ResponseMessage
|
|
|
err error
|
|
|
rsp *protocol.FileResponse = &protocol.FileResponse{}
|
|
|
)
|
|
|
defer func() {
|
|
|
this.Resp(msg)
|
|
|
}()
|
|
|
var request = &protocol.FileRequest{}
|
|
|
//if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{
|
|
|
// log.Error(err)
|
|
|
// msg = protocol.ReturnResponse(1)
|
|
|
// return
|
|
|
//}
|
|
|
//if b,m :=this.Valid(request);!b{
|
|
|
// msg = m
|
|
|
// return
|
|
|
//}
|
|
|
if request.Files, err = this.GetFiles("file"); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
for i := 1; i <= 9; i++ {
|
|
|
var tmp *protocol.FileResponse
|
|
|
key := fmt.Sprintf("%v%v", "voice", i)
|
|
|
if request.Files, err = this.GetFiles(key); err != nil {
|
|
|
log.Error(key, err)
|
|
|
err = nil
|
|
|
break
|
|
|
}
|
|
|
if tmp, err = upload.Voice(request); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp.Paths = append(rsp.Paths, tmp.Paths...)
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(upload.Voice(request))
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
|
|
}
|
|
|
|
|
|
// Video
|
...
|
...
|
@@ -76,10 +81,12 @@ func (this *UploadController) Video() { |
|
|
defer func() {
|
|
|
this.Resp(msg)
|
|
|
}()
|
|
|
var request = &protocol.FileRequest{}
|
|
|
if request.Files, err = this.GetFiles("file"); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
for i := 1; i <= 9; i++ {
|
|
|
var request = &protocol.FileRequest{}
|
|
|
if request.Files, err = this.GetFiles("file"); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(upload.Video(request))
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(upload.Video(request))
|
|
|
} |
...
|
...
|
|