当前位置: 首页>>代码示例>>C#>>正文


C# AmazonS3Client.PutACL方法代码示例

本文整理汇总了C#中Amazon.S3.AmazonS3Client.PutACL方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3Client.PutACL方法的具体用法?C# AmazonS3Client.PutACL怎么用?C# AmazonS3Client.PutACL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Amazon.S3.AmazonS3Client的用法示例。


在下文中一共展示了AmazonS3Client.PutACL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestPostUpload

        public void TestPostUpload()
        {
            var region = RegionEndpoint.USWest1;

            using (var client = new AmazonS3Client(region))
            {
                var bucketName = S3TestUtils.CreateBucket(client);
                client.PutACL(new PutACLRequest
                {
                    BucketName = bucketName,
                    CannedACL = S3CannedACL.BucketOwnerFullControl
                });

                var credentials = GetCredentials(client);
                try
                {
                    var response = testPost("foo/bar/content.txt", bucketName, testContentStream("Line one\nLine two\nLine three\n"), "", credentials, region);
                    Assert.IsNotNull(response.RequestId);
                    Assert.IsNotNull(response.HostId);
                    Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode);
                }
                finally
                {
                    AmazonS3Util.DeleteS3BucketWithObjects(client, bucketName);
                }
            }
        }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:27,代码来源:RegionsTest.cs

示例2: MakeObjectPublic

        public virtual void MakeObjectPublic(AmazonS3Client s3Client, string bucketName, string key)
        {
            // Create the request
            var putAclRequest = new PutACLRequest {
                BucketName = bucketName,
                Key = key,
                CannedACL = S3CannedACL.PublicRead
            };

            // Submit the request
            s3Client.PutACL(putAclRequest);
        }
开发者ID:jfaerman,项目名称:devonaws-labs-csharp,代码行数:12,代码来源:SolutionCode.cs

示例3: AclSamples

        public void AclSamples()
        {
            {
                #region PutACL Sample 1

                // Create a client
                AmazonS3Client client = new AmazonS3Client();

                // Set Canned ACL (PublicRead) for an existing item
                client.PutACL(new PutACLRequest
                {
                    BucketName = "SampleBucket",
                    Key = "Item1",
                    CannedACL = S3CannedACL.PublicRead
                });

                // Set Canned ACL (PublicRead) for an existing item
                // (This reverts ACL back to default for object)
                client.PutACL(new PutACLRequest
                {
                    BucketName = "SampleBucket",
                    Key = "Item1",
                    CannedACL = S3CannedACL.Private
                });

                #endregion
            }

            {
                #region GetACL\PutACL Samples

                // Create a client
                AmazonS3Client client = new AmazonS3Client();

                // Retrieve ACL for object
                S3AccessControlList acl = client.GetACL(new GetACLRequest
                {
                    BucketName = "SampleBucket",
                    Key = "Item1",
                }).AccessControlList;

                // Retrieve owner
                Owner owner = acl.Owner;


                // Describe grant
                S3Grant grant = new S3Grant
                {
                    Grantee = new S3Grantee { EmailAddress = "[email protected]" },
                    Permission = S3Permission.WRITE_ACP
                };

                // Create new ACL
                S3AccessControlList newAcl = new S3AccessControlList
                {
                    Grants = new List<S3Grant> { grant },
                    Owner = owner
                };

                // Set new ACL
                PutACLResponse response = client.PutACL(new PutACLRequest
                {
                    BucketName = "SampleBucket",
                    Key = "Item1",
                    AccessControlList = acl
                });

                #endregion
            }
        }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:70,代码来源:BaseS3Samples.cs


注:本文中的Amazon.S3.AmazonS3Client.PutACL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。