Files
rootandClaude Opus 4.7 79ac89b458 Initial commit
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-11-07 10:47:18 +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)
}