feat: add chunked desktop client release uploads
This commit is contained in:
@@ -72,12 +72,25 @@ func (c *aliyunClient) Validate() error {
|
||||
}
|
||||
|
||||
func (c *aliyunClient) PutBytes(ctx context.Context, objectKey string, content []byte, contentType string) error {
|
||||
return c.PutReader(ctx, objectKey, bytes.NewReader(content), int64(len(content)), contentType)
|
||||
}
|
||||
|
||||
func (c *aliyunClient) PutReader(
|
||||
ctx context.Context,
|
||||
objectKey string,
|
||||
reader io.Reader,
|
||||
size int64,
|
||||
contentType string,
|
||||
) error {
|
||||
if err := c.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if strings.TrimSpace(objectKey) == "" {
|
||||
return fmt.Errorf("object key is required")
|
||||
}
|
||||
if reader == nil {
|
||||
return fmt.Errorf("object reader is required")
|
||||
}
|
||||
|
||||
exists, err := c.client.IsBucketExist(c.bucket)
|
||||
if err != nil {
|
||||
@@ -113,11 +126,11 @@ func (c *aliyunClient) PutBytes(ctx context.Context, objectKey string, content [
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := bucket.PutObject(objectKey, bytes.NewReader(content), options...); err != nil {
|
||||
if err := bucket.PutObject(objectKey, reader, options...); err != nil {
|
||||
c.logError(ctx, "aliyun put object failed",
|
||||
zap.String("bucket", c.bucket),
|
||||
zap.String("object_key", objectKey),
|
||||
zap.Int("content_size", len(content)),
|
||||
zap.Int64("content_size", size),
|
||||
zap.String("object_acl", strings.TrimSpace(c.cfg.ObjectACL)),
|
||||
zap.String("content_type", contentType),
|
||||
zap.String("aliyun_error_code", aliyunErrorCode(err)),
|
||||
|
||||
Reference in New Issue
Block a user