Files
web_hgtv_server/pub/storage/upload.go
T
rootandClaude Opus 5.5 7974a42301 Initial commit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-23 11:07:42 +08:00

35 lines
758 B
Go

package storage
import (
"bytes"
"context"
"errors"
"mime/multipart"
"videoweb/pub/storage/proxy"
)
// web后台上传使用, form-data方式上传
func UploadImage(ctx context.Context, f *multipart.FileHeader, domain string) (path string, err error) {
if f == nil {
return "", errors.New("file is nil!")
}
var file multipart.File
if file, err = f.Open(); err != nil {
return
}
defer file.Close()
//mtx.Lock()
//defer mtx.Unlock()
buffer := bytes.Buffer{}
if _, err = buffer.ReadFrom(file); err != nil {
return
}
return proxy.UploadImg(f.Filename, buffer.Bytes(), domain)
}
func QueryMedias(ctx context.Context, in *proxy.MediaQueryesReq, domain string) (*proxy.VideoQuerysResult, error) {
return proxy.QueryMedias(in, domain)
}