文档中心 > 归档存储对象解冻操作
归档存储对象解冻操作

最近更新时间:2021-10-29

默认设置时间为1天,可以设置的时间范围为1-30天。

以下代码用于归档存储对象解冻操作。

using System;

using Amazon.S3;

using Amazon.S3.Model;

 

namespace RestoreObject

{

    class Program

    {

        static void Main()

        {  

            var Ak = "xxx";

            var Sk = "xx";

            var endpoint = "http://s3.test.com";

            AmazonS3Client serviceClient = new AmazonS3Client(Ak,Sk,

            new AmazonS3Config{ ServiceURL = endpoint });

 

            try

            {  

                RestoreObjectResponse response;

                RestoreObjectRequest restoreObject = new RestoreObjectRequest{

                    BucketName = "xxx",

                    Key = "xxx", // object name

                    Days = 1

                };

 

                response = serviceClient.RestoreObjectAsync(restoreObject).GetAwaiter().GetResult();

                Console.WriteLine(response.HttpStatusCode);

            

            } catch (AmazonS3Exception e) {

                Console.WriteLine(e.Data);

                throw;

            } catch (Exception e) {

                Console.WriteLine(e);

                throw;

            }

        }

    }

}