feat: add upload timeout
This commit is contained in:
@@ -84,7 +84,7 @@ func (w *DownloadFromAliOSSWorker) Work(ctx context.Context, job *Job[DownloadFr
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Starting download for file: %s", media.Path)
|
log.Infof("Starting download for file: %s", media.Path)
|
||||||
if err := w.oss.Download(ctx, media.Path, dst, ali.WithInternal(true)); err != nil {
|
if err := w.oss.Download(ctx, media.Path, dst, ali.WithInternal()); err != nil {
|
||||||
log.Errorf("Error downloading file: %v", err)
|
log.Errorf("Error downloading file: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ func (w *VideoExtractHeadImageWorker) Work(ctx context.Context, job *Job[VideoEx
|
|||||||
}
|
}
|
||||||
|
|
||||||
// upload to oss
|
// upload to oss
|
||||||
if err := w.oss.Upload(ctx, output, imageMedia.Path, ali.WithInternal(true)); err != nil {
|
if err := w.oss.Upload(ctx, output, imageMedia.Path, ali.WithInternal()); err != nil {
|
||||||
log.Errorf("Error uploading image to OSS: %v", err)
|
log.Errorf("Error uploading image to OSS: %v", err)
|
||||||
return JobCancel(err)
|
return JobCancel(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ func (w *VideoStoreShortWorker) Work(ctx context.Context, job *Job[VideoStoreSho
|
|||||||
}
|
}
|
||||||
|
|
||||||
// upload to oss
|
// upload to oss
|
||||||
if err := w.oss.Upload(ctx, job.Args.FilePath, filePath, ali.WithInternal(true)); err != nil {
|
if err := w.oss.Upload(ctx, job.Args.FilePath, filePath, ali.WithInternal()); err != nil {
|
||||||
log.Errorf("Error uploading file to OSS: %v", err)
|
log.Errorf("Error uploading file to OSS: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ func WithExpire(expire time.Duration) OSSOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithInternal(internal bool) OSSOption {
|
func WithInternal() OSSOption {
|
||||||
return func(o *OSSOptions) {
|
return func(o *OSSOptions) {
|
||||||
o.internal = internal
|
o.internal = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,10 @@ func (c *OSSClient) Upload(ctx context.Context, input, dst string, opts ...OSSOp
|
|||||||
client = c.internalClient
|
client = c.internalClient
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := client.PutObjectFromFile(ctx, request, input); err != nil {
|
ossFuncs := []func(*oss.Options){
|
||||||
|
oss.OpReadWriteTimeout(time.Minute * 20),
|
||||||
|
}
|
||||||
|
if _, err := client.PutObjectFromFile(ctx, request, input, ossFuncs...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user