40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
"oss/model/dto"
|
|
"oss/service"
|
|
|
|
"gitea.com/red-future/common/beans"
|
|
)
|
|
|
|
type file struct{}
|
|
|
|
var File = new(file)
|
|
|
|
// init 初始化表单配置
|
|
func init() {
|
|
}
|
|
|
|
// DownloadToFile 下载文件到本地
|
|
func (c *file) DownloadToFile(ctx context.Context, req *dto.DownloadToFileReq) (res *beans.ResponseEmpty, err error) {
|
|
err = service.File.DownloadToFile(ctx, req)
|
|
return
|
|
}
|
|
|
|
// DownloadToBrowser 下载文件到浏览器
|
|
func (c *file) DownloadToBrowser(ctx context.Context, req *dto.DownloadToBrowserReq) (res *beans.ResponseEmpty, err error) {
|
|
err = service.File.DownloadToBrowser(ctx, req)
|
|
return
|
|
}
|
|
|
|
// UploadFile 上传文件
|
|
func (c *file) UploadFile(ctx context.Context, req *dto.UploadFileReq) (res *dto.UploadFileRes, err error) {
|
|
return service.File.UploadFile(ctx, req)
|
|
}
|
|
|
|
// UploadFileBytes 上传文件(字节流)
|
|
func (c *file) UploadFileBytes(ctx context.Context, req *dto.UploadFileBytesReq) (res *dto.UploadFileRes, err error) {
|
|
return service.File.UploadFileBytes(ctx, req)
|
|
}
|