feat: update video cut and extract head image job
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user