feat: update video cut and extract head image job

This commit is contained in:
yanghao05
2025-04-22 10:37:57 +08:00
parent 326a9e523b
commit 284531d10e
15 changed files with 474 additions and 136 deletions

View File

@@ -2,6 +2,7 @@ package ali
import (
"context"
"path/filepath"
"strings"
"time"
@@ -14,6 +15,10 @@ type OSSClient struct {
config *Config
}
func (c *OSSClient) GetSavePath(path string) string {
return filepath.Join("quyun", strings.Trim(path, "/"))
}
func (c *OSSClient) GetClient() *oss.Client {
return c.client
}
@@ -21,7 +26,7 @@ func (c *OSSClient) GetClient() *oss.Client {
func (c *OSSClient) PreSignUpload(ctx context.Context, path, mimeType string) (*oss.PresignResult, error) {
request := &oss.PutObjectRequest{
Bucket: oss.Ptr(c.config.Bucket),
Key: oss.Ptr("quyun/" + strings.Trim(path, "/")),
Key: oss.Ptr(c.GetSavePath(path)),
ContentType: oss.Ptr(mimeType),
}
return c.client.Presign(ctx, request)
@@ -67,3 +72,16 @@ func (c *OSSClient) Delete(ctx context.Context, path string) error {
}
return nil
}
// Upload
func (c *OSSClient) Upload(ctx context.Context, input, dst string) error {
request := &oss.PutObjectRequest{
Bucket: oss.Ptr(c.config.Bucket),
Key: oss.Ptr(c.GetSavePath(dst)),
}
if _, err := c.internalClient.PutObjectFromFile(ctx, request, input); err != nil {
return err
}
return nil
}