/// <summary>
 /// Initiates the asynchronous execution of the PutACL operation.
 /// <seealso cref="Amazon.S3.IAmazonS3.PutACL"/>
 /// </summary>
 /// 
 /// <param name="putACLRequest">Container for the necessary parameters to execute the PutACL operation on IAmazonS3.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public IAsyncResult BeginPutACL(PutACLRequest putACLRequest, AsyncCallback callback, object state)
 {
     return invokePutACL(putACLRequest, callback, state, false);
 }
 IAsyncResult invokePutACL(PutACLRequest putACLRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new PutACLRequestMarshaller().Marshall(putACLRequest);
     var unmarshaller = PutACLResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Esempio n. 3
0
 /// <summary>
 /// Initiates the asynchronous execution of the PutACL operation.
 /// This API is supported only when AWSConfigs.HttpClient is set to AWSConfigs.HttpClientOption.UnityWebRequest, the default value for this configuration option is AWSConfigs.HttpClientOption.UnityWWW
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the PutACL operation on AmazonS3Client.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void PutACLAsync(PutACLRequest request, AmazonServiceCallback<PutACLRequest, PutACLResponse> callback, AsyncOptions options = null)
 {
     if (AWSConfigs.HttpClient == AWSConfigs.HttpClientOption.UnityWWW)
     {
         throw new InvalidOperationException("PutACL is only allowed with AWSConfigs.HttpClientOption.UnityWebRequest API option");
     }
     options = options == null?new AsyncOptions():options;
     var marshaller = new PutACLRequestMarshaller();
     var unmarshaller = PutACLResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<PutACLRequest,PutACLResponse> responseObject 
                     = new AmazonServiceResult<PutACLRequest,PutACLResponse>((PutACLRequest)req, (PutACLResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<PutACLRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
 /// <summary>
 /// <para>uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket</para>
 /// </summary>
 /// 
 /// <param name="putACLRequest">Container for the necessary parameters to execute the PutObjectAcl service method on AmazonS3.</param>
 /// 
 public PutACLResponse PutACL(PutACLRequest putACLRequest)
 {
     IAsyncResult asyncResult = invokePutACL(putACLRequest, null, null, true);
     return EndPutACL(asyncResult);
 }
Esempio n. 5
0
        internal PutACLResponse PutACL(PutACLRequest request)
        {
            var marshaller = new PutACLRequestMarshaller();
            var unmarshaller = PutACLResponseUnmarshaller.Instance;

            return Invoke<PutACLRequest,PutACLResponse>(request, marshaller, unmarshaller);
        }
Esempio n. 6
0
        /// <summary>
        /// <para>uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutObjectAcl service method on AmazonS3.</param>
		public PutACLResponse PutACL(PutACLRequest request)
        {
            var task = PutACLAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Initiates the asynchronous execution of the PutACL operation.
        /// <seealso cref="Amazon.S3.IAmazonS3.PutACL"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutACL operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public Task<PutACLResponse> PutACLAsync(PutACLRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PutACLRequestMarshaller();
            var unmarshaller = PutACLResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, PutACLRequest, PutACLResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.S3.Model.PutACLRequest();


            // populate AccessControlList
            var requestAccessControlListIsNull = true;

            request.AccessControlList = new Amazon.S3.Model.S3AccessControlList();
            List <Amazon.S3.Model.S3Grant> requestAccessControlList_accessControlList_Grant = null;

            if (cmdletContext.AccessControlList_Grant != null)
            {
                requestAccessControlList_accessControlList_Grant = cmdletContext.AccessControlList_Grant;
            }
            if (requestAccessControlList_accessControlList_Grant != null)
            {
                request.AccessControlList.Grants = requestAccessControlList_accessControlList_Grant;
                requestAccessControlListIsNull   = false;
            }
            Amazon.S3.Model.Owner requestAccessControlList_accessControlList_Owner = null;

            // populate Owner
            var requestAccessControlList_accessControlList_OwnerIsNull = true;

            requestAccessControlList_accessControlList_Owner = new Amazon.S3.Model.Owner();
            System.String requestAccessControlList_accessControlList_Owner_owner_DisplayName = null;
            if (cmdletContext.Owner_DisplayName != null)
            {
                requestAccessControlList_accessControlList_Owner_owner_DisplayName = cmdletContext.Owner_DisplayName;
            }
            if (requestAccessControlList_accessControlList_Owner_owner_DisplayName != null)
            {
                requestAccessControlList_accessControlList_Owner.DisplayName = requestAccessControlList_accessControlList_Owner_owner_DisplayName;
                requestAccessControlList_accessControlList_OwnerIsNull       = false;
            }
            System.String requestAccessControlList_accessControlList_Owner_owner_Id = null;
            if (cmdletContext.Owner_Id != null)
            {
                requestAccessControlList_accessControlList_Owner_owner_Id = cmdletContext.Owner_Id;
            }
            if (requestAccessControlList_accessControlList_Owner_owner_Id != null)
            {
                requestAccessControlList_accessControlList_Owner.Id    = requestAccessControlList_accessControlList_Owner_owner_Id;
                requestAccessControlList_accessControlList_OwnerIsNull = false;
            }
            // determine if requestAccessControlList_accessControlList_Owner should be set to null
            if (requestAccessControlList_accessControlList_OwnerIsNull)
            {
                requestAccessControlList_accessControlList_Owner = null;
            }
            if (requestAccessControlList_accessControlList_Owner != null)
            {
                request.AccessControlList.Owner = requestAccessControlList_accessControlList_Owner;
                requestAccessControlListIsNull  = false;
            }
            // determine if request.AccessControlList should be set to null
            if (requestAccessControlListIsNull)
            {
                request.AccessControlList = null;
            }
            if (cmdletContext.CannedACL != null)
            {
                request.CannedACL = cmdletContext.CannedACL;
            }
            if (cmdletContext.BucketName != null)
            {
                request.BucketName = cmdletContext.BucketName;
            }
            if (cmdletContext.ExpectedBucketOwner != null)
            {
                request.ExpectedBucketOwner = cmdletContext.ExpectedBucketOwner;
            }
            if (cmdletContext.Key != null)
            {
                request.Key = cmdletContext.Key;
            }
            if (cmdletContext.VersionId != null)
            {
                request.VersionId = cmdletContext.VersionId;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
Esempio n. 9
0
 public void SetACL(S3AccessControlList acl)
 {
     var request = new PutACLRequest
     {
         BucketName = this.linker.s3.bucket,
         Key = this.linker.s3.key,
         AccessControlList = acl
     };
     this.s3ClientCache.GetClient(this.RegionAsEndpoint).PutACL(request);
 }
Esempio n. 10
0
        /// <summary>
        /// <para>uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutObjectAcl service method on AmazonS3.</param>
		public PutACLResponse PutACL(PutACLRequest request)
        {
            var task = PutACLAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
Esempio n. 11
0
 public void SetACL(S3CannedACL cannedACL)
 {
     var request = new PutACLRequest
     {
         BucketName = this.linker.s3.bucket,
         Key = this.linker.s3.key,
         CannedACL = cannedACL
     };
     this.s3ClientCache.GetClient(this.RegionAsEndpoint).PutACL(request);
 }
Esempio n. 12
0
 /// <summary>
 /// If enable is set to true the object will have its permission set to PublicRead otherwise the permissions will be set to Private.
 /// </summary>
 /// <param name="enable">If true the object will have its permission set to PublicRead otherwise the permissions will be set to Private.</param>
 public void MakeS3ObjectPublic(bool enable) 
 {
     var request = new PutACLRequest
     {
         BucketName = this.linker.s3.bucket,
         Key = this.linker.s3.key,
         CannedACL = enable ? S3CannedACL.PublicRead : S3CannedACL.Private
     };
     this.s3ClientCache.GetClient(this.RegionAsEndpoint).PutACL(request);
 }
Esempio n. 13
0
        /// <summary>
        /// <para>uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket</para>
        /// </summary>
        /// 
        /// <param name="putACLRequest">Container for the necessary parameters to execute the PutObjectAcl service method on AmazonS3.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<PutACLResponse> PutACLAsync(PutACLRequest putACLRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PutACLRequestMarshaller();
            var unmarshaller = PutACLResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, PutACLRequest, PutACLResponse>(putACLRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
 public void SetFileAcl(string key) {
     var request = new PutACLRequest();
     request.Key = key;
     request.BucketName = BucketName;
     request.CannedACL = S3CannedACL.PublicRead;
     var response = _client.PutACL(request);
 }
 void ICoreAmazonS3.MakeObjectPublic(string bucket, string objectKey, bool enable)
 {
     var request = new PutACLRequest
     {
         BucketName = bucket,
         Key = objectKey,
         CannedACL = enable ? S3CannedACL.PublicRead : S3CannedACL.Private
     };
     this.PutACL(request);
 }
        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);
        }
        /// <summary>
        /// Sets up the request needed to make an exact copy of the object leaving the parent method
        /// the ability to change just the attribute being requested to change.
        /// </summary>
        /// <param name="bucketName"></param>
        /// <param name="key"></param>
        /// <param name="version"></param>
        /// <param name="s3Client"></param>
        /// <param name="copyRequest"></param>
        /// <param name="putACLRequest"></param>
        static void SetupForObjectModification(IAmazonS3 s3Client, string bucketName, string key, string version, 
            out CopyObjectRequest copyRequest, out PutACLRequest putACLRequest)
        {
            // Get the existing ACL of the object
            GetACLRequest getACLRequest = new GetACLRequest();
            getACLRequest.BucketName = bucketName;
            getACLRequest.Key = key;
            if (version != null)
                getACLRequest.VersionId = version;
            GetACLResponse getACLResponse = s3Client.GetACL(getACLRequest);


            // Set the object's original ACL back onto it because a COPY
            // operation resets the ACL on the destination object.
            putACLRequest = new PutACLRequest();
            putACLRequest.BucketName = bucketName;
            putACLRequest.Key = key;
            putACLRequest.AccessControlList = getACLResponse.AccessControlList;


            ListObjectsResponse listObjectResponse = s3Client.ListObjects(new ListObjectsRequest
            {
                BucketName = bucketName,
                Prefix = key,
                MaxKeys = 1
            });

            if (listObjectResponse.S3Objects.Count != 1)
            {
                throw new InvalidOperationException("No object exists with this bucket name and key.");
            }

            GetObjectMetadataRequest getMetaRequest = new GetObjectMetadataRequest()
            {
                BucketName = bucketName,
                Key = key
            };
            GetObjectMetadataResponse getMetaResponse = s3Client.GetObjectMetadata(getMetaRequest);

            // Set the storage class on the object
            copyRequest = new CopyObjectRequest();
            copyRequest.SourceBucket = copyRequest.DestinationBucket = bucketName;
            copyRequest.SourceKey = copyRequest.DestinationKey = key;
            copyRequest.StorageClass = listObjectResponse.S3Objects[0].StorageClass == "STANDARD" ? S3StorageClass.Standard : S3StorageClass.ReducedRedundancy;
            if (version != null)
                copyRequest.SourceVersionId = version;

            copyRequest.WebsiteRedirectLocation = getMetaResponse.WebsiteRedirectLocation;
            copyRequest.ServerSideEncryptionMethod = getMetaResponse.ServerSideEncryptionMethod;
        }
 private Amazon.S3.Model.PutACLResponse CallAWSServiceOperation(IAmazonS3 client, Amazon.S3.Model.PutACLRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Storage Service (S3)", "PutACL");
     try
     {
         #if DESKTOP
         return(client.PutACL(request));
         #elif CORECLR
         return(client.PutACLAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
Esempio n. 19
0
        /// <summary>
        /// Initiates the asynchronous execution of the PutACL operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutACL operation on AmazonS3Client.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndPutACL
        ///         operation.</returns>
        public IAsyncResult BeginPutACL(PutACLRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new PutACLRequestMarshaller();
            var unmarshaller = PutACLResponseUnmarshaller.Instance;

            return BeginInvoke<PutACLRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Esempio n. 20
0
        /// <summary>
        /// Initiates the asynchronous execution of the PutACL operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutACL operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<PutACLResponse> PutACLAsync(PutACLRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PutACLRequestMarshaller();
            var unmarshaller = PutACLResponseUnmarshaller.Instance;

            return InvokeAsync<PutACLRequest,PutACLResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Esempio n. 21
0
        /// <summary>
        /// Set access rights of an object.
        /// </summary>
        /// <param name="bucketName">The name of the bucket.</param>
        /// <param name="key">The key of the object.</param>
        /// <param name="acl">The desired access rights.</param>
        public void SetAcl(string bucketName, string key, S3CannedACL acl)
        {
            var request = new PutACLRequest
                              {
                                  BucketName = bucketName,
                                  CannedACL = acl,
                                  Key = key
                              };

            _amazonS3Client.PutACL(request);
        }