|
|
package v1
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"opp/controllers"
|
|
|
"opp/protocol"
|
|
|
"opp/services/upload"
|
...
|
...
|
@@ -25,19 +24,16 @@ func (this *UploadController) Image() { |
|
|
this.Resp(msg)
|
|
|
}()
|
|
|
var request = &protocol.FileRequest{}
|
|
|
for i := 1; i <= 9; i++ {
|
|
|
if len(this.Ctx.Request.MultipartForm.File) != 0 {
|
|
|
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
|
|
|
for _, v := range this.Ctx.Request.MultipartForm.File {
|
|
|
request.Files = v
|
|
|
if tmp, err = upload.Image(request); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp.Paths = append(rsp.Paths, tmp.Paths...)
|
|
|
}
|
|
|
if tmp, err = upload.Image(request); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp.Paths = append(rsp.Paths, tmp.Paths...)
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
|
|
}
|
...
|
...
|
@@ -54,19 +50,16 @@ func (this *UploadController) Voice() { |
|
|
this.Resp(msg)
|
|
|
}()
|
|
|
var request = &protocol.FileRequest{}
|
|
|
for i := 1; i <= 9; i++ {
|
|
|
if len(this.Ctx.Request.MultipartForm.File) != 0 {
|
|
|
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
|
|
|
for _, v := range this.Ctx.Request.MultipartForm.File {
|
|
|
request.Files = v
|
|
|
if tmp, err = upload.Voice(request); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp.Paths = append(rsp.Paths, tmp.Paths...)
|
|
|
}
|
|
|
rsp.Paths = append(rsp.Paths, tmp.Paths...)
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
|
|
}
|
...
|
...
|
@@ -77,16 +70,22 @@ func (this *UploadController) Video() { |
|
|
var (
|
|
|
msg *protocol.ResponseMessage
|
|
|
err error
|
|
|
rsp *protocol.FileResponse = &protocol.FileResponse{}
|
|
|
)
|
|
|
defer func() {
|
|
|
this.Resp(msg)
|
|
|
}()
|
|
|
for i := 1; i <= 9; i++ {
|
|
|
var request = &protocol.FileRequest{}
|
|
|
if request.Files, err = this.GetFiles("file"); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
var request = &protocol.FileRequest{}
|
|
|
if len(this.Ctx.Request.MultipartForm.File) != 0 {
|
|
|
var tmp *protocol.FileResponse
|
|
|
for _, v := range this.Ctx.Request.MultipartForm.File {
|
|
|
request.Files = v
|
|
|
if tmp, err = upload.Video(request); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
rsp.Paths = append(rsp.Paths, tmp.Paths...)
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(upload.Video(request))
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
|
|
} |
...
|
...
|
|