Beispiel #1
0
        public void SetACL(string fileKey, bool anonymouseReadAccess)
        {
            SetACLRequest aclRequest = new SetACLRequest();

            aclRequest.Key        = fileKey;
            aclRequest.BucketName = BucketName;

            S3AccessControlList aclList = new S3AccessControlList();

            Owner owner = new Owner();

            owner.Id          = "oyesil";
            owner.DisplayName = "";
            aclList.Owner     = owner;

            if (anonymouseReadAccess)
            {
                S3Grantee grantPublicRead = new S3Grantee();
                grantPublicRead.URI = " http://acs.amazonaws.com/groups/global/AllUsers";
                aclList.AddGrant(grantPublicRead, S3Permission.READ);
            }

            //Authenticated user read access
            S3Grantee grantAuthenticatedRead = new S3Grantee();

            grantAuthenticatedRead.URI = " http://acs.amazonaws.com/groups/global/AuthenticatedUsers";
            aclList.AddGrant(grantAuthenticatedRead, S3Permission.READ);

            aclRequest.ACL = aclList;


            Amazon.S3.AmazonS3Client client = new Amazon.S3.AmazonS3Client(ConfigurationLibrary.Config.fileAmazonS3AccessKey,
                                                                           ConfigurationLibrary.Config.fileAmazonS3SecreyKey);
            SetACLResponse aclResponse = client.SetACL(aclRequest);

            client.Dispose();
        }