Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestoreObject is asynchronous? #436

Open
BlackSinny opened this issue Mar 28, 2024 · 0 comments
Open

RestoreObject is asynchronous? #436

BlackSinny opened this issue Mar 28, 2024 · 0 comments

Comments

@BlackSinny
Copy link

i want to restore file use func RestoreObject on sdk
my code like this

func AliAttachRestore() error {
	client, err := oss.New(aliendpoint, alikey, alisecret)
	if err != nil {
		return err
	}
	b, err := client.Bucket(alibucket)
	if err != nil {
		return err
	}
	//1. 先解冻
	err = b.RestoreObject(alidfsid)
	if err != nil {
		fmt.Println("restore err", err)
		fmt.Println("restore err", err.Error())
		return err
	}

	//2. 再修改存储类型为低频访问
	//StatusCode=400, ErrorCode=OperationNotSupported, ErrorMessage="The operation is not supported for this resource", RequestId=65FBF1EF6CF4DEAE7A289C1F, Ec=0016-00000702
	_, err = b.CopyObject(alidfsid, alidfsid, oss.ObjectStorageClass(oss.StorageIA))
	if err != nil {
		fmt.Println("copyObject err:", err)
		fmt.Println("copyObject err:", err.Error())
		if strings.Contains(err.Error(), "Ec=0016-00000702") {
			fmt.Println("status not allow")
			return nil
		}
		return err
	}
	
	fmt.Println("success")
	return nil
}

when first run code ,i receive err

copyObject err: oss: service returned error: StatusCode=403, ErrorCode=InvalidObjectState, ErrorMessage="The operation is not valid for the object's state", RequestId=6605418D3D849617A272A1F0, Ec=0016-00000330
  • if i try immediately , receive err like this
oss: service returned error: StatusCode=409, ErrorCode=RestoreAlreadyInProgress, ErrorMessage="The restore operation is in progress.", RequestId=660541A76AA16F56DBB8031F, Ec=0016-00000701
  1. so what do I do if I need to synchronize and wait to restore a file?
  2. RestoreObject and CopyObject have any error code desc?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant