feat: add upload timeout

This commit is contained in:
Rogee
2025-05-06 11:13:49 +08:00
parent 72ab4ad7ec
commit bb689c62e1
4 changed files with 9 additions and 6 deletions

View File

@@ -22,9 +22,9 @@ func WithExpire(expire time.Duration) OSSOption {
}
}
func WithInternal(internal bool) OSSOption {
func WithInternal() OSSOption {
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
}
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 nil