private SetObjectAclCommand(IServiceClient client, Uri endpoint, ExecutionContext context, SetObjectAclRequest request) : base(client, endpoint, context) { _request = request; }
private SetObjectAclCommand(IServiceClient client, Uri endpoint, ExecutionContext context, SetObjectAclRequest request) : base(client, endpoint, context) { _request = request; }
public static SetObjectAclCommand Create(IServiceClient client, Uri endpoint, ExecutionContext context, SetObjectAclRequest request) { OssUtils.CheckBucketName(request.BucketName); OssUtils.CheckObjectKey(request.Key); return(new SetObjectAclCommand(client, endpoint, context, request)); }
public static SetObjectAclCommand Create(IServiceClient client, Uri endpoint, ExecutionContext context, SetObjectAclRequest request) { OssUtils.CheckBucketName(request.BucketName); OssUtils.CheckObjectKey(request.Key); return new SetObjectAclCommand(client, endpoint, context, request); }
/// <summary> /// Start the asynchronous request for configuring an object ACL. /// </summary> /// <param name="request">Parameters in a request for configuring an object ACL</param> /// <param name="callback">Asynchronous request callback function</param> /// <param name="state">Asynchronous request status object</param> /// <returns>Response to the asynchronous request</returns> public IAsyncResult BeginSetObjectAcl(SetObjectAclRequest request, AsyncCallback callback, object state) { return(this.BeginDoRequest <SetObjectAclRequest>(request, delegate() { if (request.ObjectKey == null) { throw new ObsException(Constants.InvalidObjectKeyMessage, ErrorType.Sender, Constants.InvalidObjectKey, ""); } }, callback, state)); }
/// <summary> /// Set an object ACL. /// </summary> /// <param name="request">Parameters in a request for configuring an object ACL</param> /// <returns>Response to a request for configuring an object ACL</returns> public SetObjectAclResponse SetObjectAcl(SetObjectAclRequest request) { return(this.DoRequest <SetObjectAclRequest, SetObjectAclResponse>(request, delegate() { if (request.ObjectKey == null) { throw new ObsException(Constants.InvalidObjectKeyMessage, ErrorType.Sender, Constants.InvalidObjectKey, ""); } })); }
public void ObjectAclTest() { var key = OssTestUtils.GetObjectKey(_className); _ossClient.PutObject(_bucketName, key, Config.UploadTestFile); var getRequest = new GetObjectAclRequest(_bucketName, key); Assert.AreEqual(getRequest.RequestPayer, RequestPayer.BucketOwner); var setRequest = new SetObjectAclRequest(_bucketName, key, CannedAccessControlList.PublicRead); Assert.AreEqual(setRequest.RequestPayer, RequestPayer.BucketOwner); try { _ossPayerClient.GetObjectAcl(getRequest); Assert.Fail("should not here."); } catch (OssException e) { Assert.AreEqual(e.ErrorCode, "AccessDenied"); } try { _ossPayerClient.SetObjectAcl(setRequest); Assert.Fail("should not here."); } catch (OssException e) { Assert.AreEqual(e.ErrorCode, "AccessDenied"); } setRequest.RequestPayer = RequestPayer.Requester; getRequest.RequestPayer = RequestPayer.Requester; _ossPayerClient.SetObjectAcl(setRequest); var getResult = _ossPayerClient.GetObjectAcl(getRequest); Assert.AreEqual(getResult.ACL, CannedAccessControlList.PublicRead); setRequest = new SetObjectAclRequest(_bucketName, key, CannedAccessControlList.PublicReadWrite); setRequest.RequestPayer = RequestPayer.Requester; _ossPayerClient.SetObjectAcl(setRequest); getResult = _ossPayerClient.GetObjectAcl(getRequest); Assert.AreEqual(getResult.ACL, CannedAccessControlList.PublicReadWrite); }
public static void SetObjectAclWithRequest(string bucketName) { try { client.PutObject(bucketName, key, fileToUpload); var request = new SetObjectAclRequest(bucketName, key, CannedAccessControlList.PublicRead); client.SetObjectAcl(request); Console.WriteLine("Set Object:{0} Acl succeeded ", key); } catch (OssException ex) { Console.WriteLine("Failed with error code: {0}; Error info: {1}. \nRequestID:{2}\tHostID:{3}", ex.ErrorCode, ex.Message, ex.RequestId, ex.HostId); } catch (Exception ex) { Console.WriteLine("Failed with error info: {0}", ex.Message); } }
public static void SetObjectAclWithRequest(string bucketName) { try { client.PutObject(bucketName, key, fileToUpload); var request = new SetObjectAclRequest(bucketName, key, CannedAccessControlList.PublicRead); client.SetObjectAcl(request); Console.WriteLine("Set Object:{0} Acl succeeded ", key); } catch (OssException ex) { Console.WriteLine("Failed with error code: {0}; Error info: {1}. \nRequestID:{2}\tHostID:{3}", ex.ErrorCode, ex.Message, ex.RequestId, ex.HostId); } catch (Exception ex) { Console.WriteLine("Failed with error info: {0}", ex.Message); } }
static void SetObjectACL() { try { SetObjectAclRequest request = new SetObjectAclRequest() { BucketName = bucketName, ObjectKey = objectName, CannedAcl = CannedAclEnum.PublicRead }; SetObjectAclResponse response = client.SetObjectAcl(request); Console.WriteLine("Set object acl response: {0}.", response.StatusCode); } catch (ObsException ex) { Console.WriteLine("Exception errorcode: {0}, when set object acl.", ex.ErrorCode); Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage); } }