feat: 长文本语音合成
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"path/filepath"
|
||||
@@ -104,3 +105,19 @@ func (m *Minio) DeleteFile(key string) error {
|
||||
err := m.Client.RemoveObject(ctx, m.bucket, key, minio.RemoveObjectOptions{})
|
||||
return err
|
||||
}
|
||||
|
||||
// UploadBytes 上传字节数据
|
||||
func (m *Minio) UploadBytes(data []byte, key, contentType string) (string, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*10)
|
||||
defer cancel()
|
||||
|
||||
buffer := bytes.NewReader(data)
|
||||
info, err := m.Client.PutObject(ctx, m.bucket, key, buffer, int64(len(data)), minio.PutObjectOptions{
|
||||
ContentType: contentType,
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("上传文件到minio失败: %v", err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/%s", global.Config.Minio.BucketUrl, info.Key), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user