The DeleteObjectRequest contains the parameters used for the DeleteObject operation.
Required Parameters: BucketName, Key
The MfaCodes property is required if the bucket containing this object has been configured with the EnableMfaDelete property. For more information, please see: P:Amazon.S3.Model.S3BucketVersioningConfig.EnableMfaDelete.
Inheritance: Amazon.S3.Model.S3Request
Ejemplo n.º 1
1
 public void DeleteFile(String filename)
 {
     String key = filename;
     var amazonClient = new AmazonS3Client(_keyPublic, _keySecret);
     var deleteObjectRequest = new DeleteObjectRequest { BucketName = _bucket, Key = key };
     var response = amazonClient.DeleteObject(deleteObjectRequest);
 }
Ejemplo n.º 2
1
 public static void DeletingAnObject(AmazonS3Client client, string bucketName, string keyName)
 {
     DeleteObjectRequest request = new DeleteObjectRequest();
         request.WithBucketName(bucketName)
             .WithKey(keyName);
         S3Response response = client.DeleteObject(request);
         response.Dispose();
 }
Ejemplo n.º 3
1
        public static void DeleteFromBucket(string bucketName, string key)
        {
            using (var client = new AmazonS3Client(Settings.AccessKey, Settings.Secret))
            {
                var request = new DeleteObjectRequest()
                {
                    BucketName = bucketName,
                    Key = key
                };

                client.DeleteObject(request);
            }
        }
        // Delete file from the server
        private void DeleteFile(HttpContext context)
        {
            var _getlen = 10;
                var fileName = context.Request["f"];
                var fileExt = fileName.Remove(0,fileName.LastIndexOf('.')).ToLower();
                var hasThumb =  Regex.Match(fileName.ToLower(),AmazonHelper.ImgExtensions()).Success;
                var keyName = GetKeyName(context,HttpUtility.UrlDecode(context.Request["f"]));
                var client = AmazonHelper.GetS3Client();
                var extrequest = new GetObjectRequest()
                                        .WithByteRange(0,_getlen)
                                        .WithKey(keyName)
                                        .WithBucketName(StorageRoot);
                var extresponse = client.GetObject(extrequest);
                var length = extresponse.ContentLength;
                extresponse.Dispose();
                if(length == _getlen + 1){

                    var delrequest = new DeleteObjectRequest()
                                            .WithKey(keyName)
                                            .WithBucketName(StorageRoot);
                    var delresponse = client.DeleteObject(delrequest);
                    delresponse.Dispose();
                    if(hasThumb){
                        try
                        {
                            keyName = keyName.Replace(fileName,"thumbs/" + fileName.Replace(fileExt,".png"));
                            var thumbcheck = new GetObjectRequest()
                                                    .WithByteRange(0,_getlen)
                                                    .WithKey(keyName)
                                                    .WithBucketName(StorageRoot);
                            var thumbCheckResponse = client.GetObject(thumbcheck);
                            length = extresponse.ContentLength;
                            thumbCheckResponse.Dispose();
                            if(length == _getlen + 1){
                                var thumbdelrequest = new DeleteObjectRequest()
                                                        .WithKey(keyName)
                                                        .WithBucketName(StorageRoot);
                                var thumbdelresponse = client.DeleteObject(thumbdelrequest);
                                delresponse.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {

                           var messg = ex.Message;
                        }
                    }

                }
        }
Ejemplo n.º 5
0
    public string DeleteImageFile(Hashtable State, string url)
    {
        string AWSAccessKey = ConfigurationManager.AppSettings["AWSAccessKey"];
        string AWSSecretKey = ConfigurationManager.AppSettings["AWSSecretKey"];
        string Bucket = ConfigurationManager.AppSettings["ImageBucket"];
        TransferUtility transferUtility = new TransferUtility(AWSAccessKey, AWSSecretKey);
        try
        {
            DeleteObjectRequest request = new DeleteObjectRequest();
            string file_name = url.Substring(url.LastIndexOf("/") + 1);
            string key = State["Username"].ToString() + "/" + file_name;
            request.WithBucketName(Bucket)
                .WithKey(key);
            using (DeleteObjectResponse response = transferUtility.S3Client.DeleteObject(request))
            {
                WebHeaderCollection headers = response.Headers;
             }
        }
        catch (AmazonS3Exception ex)
        {
            Util util = new Util();
            util.LogError(State, ex);
            return ex.Message + ": " + ex.StackTrace;
        }

        return "OK";
    }
        public async Task <DeleteObjectResponse> DeleteObjectAsync(string bucket,
                                                                   string key,
                                                                   CancellationToken cancellationToken = default)
        {
            this.Logger.LogDebug($"[{nameof(this.DeleteObjectAsync)}]");

            this.Logger.LogTrace(JsonConvert.SerializeObject(new { bucket, key }));

            if (string.IsNullOrWhiteSpace(bucket))
            {
                throw new ArgumentNullException(nameof(bucket));
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            var request = new Amazon.S3.Model.DeleteObjectRequest
            {
                BucketName = bucket,
                Key        = key,
            };

            this.Logger.LogTrace(JsonConvert.SerializeObject(value: request));

            var response = await this.Repository.DeleteObjectAsync(request : request,
                                                                   cancellationToken : cancellationToken == default?this.CancellationToken.Token : cancellationToken);

            this.Logger.LogTrace(JsonConvert.SerializeObject(value: response));

            return(response);
        }
        public void DeleteDocument(string keyName)
        {
            try
            {
                using (var client = GetClient)
                {

                    DeleteObjectRequest request = new DeleteObjectRequest();
                    request.WithBucketName(ImagesBucketName)
                        .WithKey(keyName);

                    client.DeleteObject(request);
                }
            }
            catch (AmazonS3Exception amazonS3Exception)
            {
                if (amazonS3Exception.ErrorCode != null &&
                    (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||
                    amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
                {
                    throw new Exception("Please check the provided AWS Credentials.");
                }
                else
                {
                    throw new Exception(string.Format("An error occurred with the message '{0}' when deleting an object", amazonS3Exception.Message));
                }
            }
        }
Ejemplo n.º 8
0
        public static S3Response PhysicallyDeletePhoto(AmazonS3 anS3Client, string aBucketName, string aFileName)
        {
            DeleteObjectRequest myDeleteRequest = new DeleteObjectRequest();
            myDeleteRequest.WithBucketName(aBucketName).WithKey(aFileName);

            return anS3Client.DeleteObject(myDeleteRequest);
        }
        public void TestCleanup()
        {
            var deleteRequest = new DeleteObjectRequest()
                .WithBucketName(bucket.BucketName)
                .WithKey(this.objKey);

            using (var deleteResponse = client.DeleteObject(deleteRequest)) { }
        }
Ejemplo n.º 10
0
 private static void DeleteS3Object(string key)
 {
     DeleteObjectRequest deleteRequest = new DeleteObjectRequest
                                             {
                                                 BucketName = BucketName,
                                                 Key = key
                                             };
     _amazonS3Client.DeleteObject(deleteRequest);
 }
Ejemplo n.º 11
0
 protected override void ProcessRecord()
 {
     AmazonS3 client = base.GetClient();
     Amazon.S3.Model.DeleteObjectRequest request = new Amazon.S3.Model.DeleteObjectRequest();
     request.BucketName = this._BucketName;
     request.Key = this._Key;
     request.VersionId = this._VersionId;
     Amazon.S3.Model.DeleteObjectResponse response = client.DeleteObject(request);
 }
Ejemplo n.º 12
0
 private async Task<DeleteObjectResponse> DeleteItemAsync(AmazonS3Client s3Client, string bucketName, string path, CancellationToken token)
 {
     var request = new DeleteObjectRequest()
     {
         BucketName = bucketName,
         Key = path + _itemChange.Item.Path
     };
     return await s3Client.DeleteObjectAsync(request, token);
 }
Ejemplo n.º 13
0
 public static void DeleteFile(AmazonS3 Client, string filekey)
 {
     DeleteObjectRequest request = new DeleteObjectRequest()
     {
         BucketName = BUCKET_NAME,
         Key = filekey
     };
     S3Response response = Client.DeleteObject(request);
 }
        public void StateDelete(string appId, string key)
        {
            var deleteObjectRequest = new DeleteObjectRequest
            {
                BucketName = ConfigurationManager.AppSettings["BucketName"],
                Key = string.Format("{0}/{1}", appId, key)
            };

            WebApiApplication.AmazonS3Client.DeleteObject(deleteObjectRequest);
        }
Ejemplo n.º 15
0
 void ICoreAmazonS3.Delete(string bucketName, string objectKey, IDictionary<string, object> additionalProperties)
 {
     var request = new DeleteObjectRequest
     {
         BucketName = bucketName,
         Key = objectKey
     };
     InternalSDKUtils.ApplyValues(request, additionalProperties);
     this.DeleteObject(request);
 }
Ejemplo n.º 16
0
 public static void RemoveFileFromBucket(string fileName)
 {
     // remove file from S3
     var client = InitS3Client();
     DeleteObjectRequest request = new DeleteObjectRequest();
     request.WithBucketName(WebConfig.Get("awsbucket"));
     request.Key = fileName;
     S3Response response = client.DeleteObject(request);
     response.Dispose();
 }
Ejemplo n.º 17
0
 //Deletes a file
 public void Delete(string fileName)
 {
     IAmazonS3 client = GetS3Client();
     var request = new DeleteObjectRequest
     {
         BucketName = _BucketName,
         Key = _Prefix + fileName
     };
     client.DeleteObject(request);
 }
Ejemplo n.º 18
0
 protected override void ExecuteS3Task()
 {
     using ( AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client( this.AccessKey, this.SecretAccessKey ) ) {
         DeleteObjectRequest request = new DeleteObjectRequest {
             BucketName = this.BucketName,
             Key = this.File
         };
         client.DeleteObject( request );
     }
 }
Ejemplo n.º 19
0
 Task ICoreAmazonS3.DeleteAsync(string bucketName, string objectKey, IDictionary<string, object> additionalProperties, CancellationToken cancellationToken)
 {
     var request = new DeleteObjectRequest
     {
         BucketName = bucketName,
         Key = objectKey
     };
     InternalSDKUtils.ApplyValues(request, additionalProperties);
     return this.DeleteObjectAsync(request, cancellationToken);
 }
Ejemplo n.º 20
0
        public void DeletingObject(string keyName)
        {
            var deleteRequest = new DeleteObjectRequest();
            deleteRequest.WithBucketName(BucketName)
                .WithKey(keyName);

            using (AmazonS3 client = AWSClientFactory.CreateAmazonS3Client(AccessKeyId, SecretAccessKeyId))
            {
                DeleteObjectResponse response = client.DeleteObject(deleteRequest);
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Deletes a file
        /// </summary>
        /// <param name="path">Web path to file's folder</param>
        /// <param name="fileName">File name</param>
        public void DeleteFile(string path, string fileName)
        {
            // Prepare delete request
            var request = new DeleteObjectRequest();
            request.WithBucketName(_bucketName)
                .WithKey(GetKey(path, fileName));

            // Delete file
            var response = _client.DeleteObject(request);
            response.Dispose();
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Deletes the image including all thumbnails
 /// </summary>
 public override void Delete()
 {
     try {
         var request = new DeleteObjectRequest().WithBucketName(_provider.BucketName).WithKey(this._virtualPath.Replace(_provider.VirtualPathRoot, string.Empty));
         this._client.DeleteObject(request);
     } catch (AmazonS3Exception exception) {
         if (exception.StatusCode == HttpStatusCode.NotFound) {
             throw new FileNotFoundException();
         }
     }
 }
Ejemplo n.º 23
0
        public bool Delete(string key)
        {
            DeleteObjectRequest request = new DeleteObjectRequest
            {
                BucketName = Bucket,
                Key = key
            };

            var response = S3Client.DeleteObject(request);

            return response.HttpStatusCode == HttpStatusCode.NoContent;
        }
Ejemplo n.º 24
0
        public bool DeleteRequest(string source)
        {
            var key = source.Replace(_baseStorageEndpoint, "");

            var deleteRequest = new DeleteObjectRequest()
                .WithBucketName(_configuration.BucketName)
                .WithKey(key);

            var response = _client.DeleteObject(deleteRequest);

            return true;
        }
Ejemplo n.º 25
0
        private void EditFile(HttpChallenge httpChallenge, bool delete, TextWriter msg)
        {
            var filePath = httpChallenge.FilePath;

            // We need to strip off any leading '/' in the path or
            // else it creates a path with an empty leading segment
            if (filePath.StartsWith("/"))
            {
                filePath = filePath.Substring(1);
            }

            using (var s3 = new Amazon.S3.AmazonS3Client(
                       CommonParams.ResolveCredentials(),
                       CommonParams.RegionEndpoint))
            {
                if (delete)
                {
                    LOG.Debug("Deleting S3 object at Bucket [{0}] and Key [{1}]", BucketName, filePath);
                    var s3Requ = new Amazon.S3.Model.DeleteObjectRequest
                    {
                        BucketName = BucketName,
                        Key        = filePath,
                    };
                    var s3Resp = s3.DeleteObject(s3Requ);
                    if (LOG.IsDebugEnabled)
                    {
                        LOG.Debug("Delete response: [{0}]",
                                  NLog.Targets.DefaultJsonSerializer.Instance.SerializeObject(s3Resp));
                    }

                    msg.WriteLine("* Challenge Response has been deleted from S3");
                    msg.WriteLine("    at Bucket/Key: [{0}/{1}]", BucketName, filePath);
                }
                else
                {
                    var s3Requ = new Amazon.S3.Model.PutObjectRequest
                    {
                        BucketName  = BucketName,
                        Key         = filePath,
                        ContentBody = httpChallenge.FileContent,
                        ContentType = ContentType,
                        CannedACL   = S3CannedAcl,
                    };
                    var s3Resp = s3.PutObject(s3Requ);

                    msg.WriteLine("* Challenge Response has been written to S3");
                    msg.WriteLine("    at Bucket/Key: [{0}/{1}]", BucketName, filePath);
                    msg.WriteLine("* Challenge Response should be accessible with a MIME type of [text/json]");
                    msg.WriteLine("    at: [{0}]", httpChallenge.FileUrl);
                }
            }
        }
Ejemplo n.º 26
0
        public static void Cleanup()
        {
            foreach (string key in cleanupKeys)
            {
                DeleteObjectRequest request = new DeleteObjectRequest()
                        .WithBucketName(BucketName)
                        .WithKey(key);

                using (DeleteObjectResponse response = Client.DeleteObject(request))
                {
                }
            }
        }
        public override void Delete(string container, string fileName)
        {
            client = AWSClientFactory.CreateAmazonS3Client(this.ExtendedProperties["accessKey"], this.ExtendedProperties["secretKey"], RegionEndpoint.USEast1);
            String S3_KEY = fileName;

            DeleteObjectRequest request = new DeleteObjectRequest()
            {
                BucketName = container,
                Key = S3_KEY,
            };

            DeleteObjectResponse response = client.DeleteObject(request);
        }
Ejemplo n.º 28
0
        public void DeleteFromBucket(string filename)
        {
            using (var client = new AmazonS3Client(accessKey, AWSSecretKey, Amazon.RegionEndpoint.USEast1))
            {
                var request = new DeleteObjectRequest()
                {
                    BucketName = bucketName,
                    Key        = filename
                };

                client.DeleteObject(request);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Deletes a file
        /// </summary>
        /// <param name="path">Web path to file's folder</param>
        /// <param name="fileName">File name</param>
        public void DeleteFile(string path, string fileName)
        {
            // Prepare delete request
            var request = new DeleteObjectRequest()
            {
                BucketName = _bucketName,
                Key = GetKey(path, fileName)
            };

            // Delete file
            var response = _client.DeleteObject(request);
            response.DisposeIfDisposable();
        }
Ejemplo n.º 30
0
        public static DeleteObjectResponse DeleteBucketItem(string itemKey, string bucketName)
        {
            var awsClient = AWSClientFactory.CreateAmazonS3Client(Properties.Resources.AmazonAccessKeyId,
                                              Properties.Resources.SecretAccessKeyId,
                                              new AmazonS3Config().WithCommunicationProtocol
                                                  (Protocol.HTTP));

            var deleteObjectRequest = new DeleteObjectRequest
                                          {
                                              BucketName = bucketName,
                                              Key = itemKey,
                                          };

            var deleteBucketResponse = awsClient.DeleteObject(deleteObjectRequest);
            return deleteBucketResponse;
        }
Ejemplo n.º 31
0
 public void DeleteObject(string bucket, string fileNmae)
 {
     try
     {
         var request = new DeleteObjectRequest
         {
             BucketName = bucket,
             Key = fileNmae
         };
         _s3Client.DeleteObject(request);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Ejemplo n.º 32
0
        public void S3DeleteItem(string bucketName, string keyName)
        {
            //ref: http://docs.aws.amazon.com/AmazonS3/latest/dev/DeletingOneObjectUsingNetSDK.html

            using (var client = new AmazonS3Client(this.AcesssKey, this.SecretKey, this.Region))
            {
                DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest
                {
                    BucketName = bucketName,
                    Key = keyName
                };

                client.DeleteObject(deleteObjectRequest);
                System.Diagnostics.Debug.WriteLine(string.Format("AwsS3 -- Deleted {0}", keyName));
            }
        }
Ejemplo n.º 33
0
        public string DeleteFile(string sFolder, string sObjectKey)
        {
            AmazonS3 client      = AWSClientFactory.CreateAmazonS3Client(S3ACCESSKEY, S3SECRETKEY);
            string   BUCKET_NAME = ConfigurationManager.AppSettings["AWSBUCKET"];

            if (sFolder != "")
            {
                sObjectKey = sFolder + "/" + sObjectKey;
            }

            DeleteObjectRequest deleteRequest = new Amazon.S3.Model.DeleteObjectRequest();

            deleteRequest.WithBucketName(BUCKET_NAME);
            deleteRequest.WithKey(sObjectKey);
            DeleteObjectResponse response = client.DeleteObject(deleteRequest);

            return(response.ResponseXml);
        }
Ejemplo n.º 34
0
        //public void SetACL(string fileKey, bool anonymouseReadAccess)
        //{
        //    SetACLRequest aclRequest = new SetACLRequest();
        //    aclRequest.Key = fileKey;
        //    aclRequest.BucketName = AWAPI_File_AmazonS3_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(AWAPI_File_AmazonS3_AccessKey, AWAPI_File_AmazonS3_SecretKey);
        //    SetACLResponse aclResponse = client.SetACL(aclRequest);

        //    client.Dispose();
        //}

        /// <summary>
        /// Deletes file from s3
        /// </summary>
        /// <returns></returns>
        public bool Delete(string fileUrl)
        {
            try
            {
                string key = GetKeyNameFromUrl(fileUrl);
                Amazon.S3.AmazonS3Client            client = new Amazon.S3.AmazonS3Client(AWAPI_File_AmazonS3_AccessKey, AWAPI_File_AmazonS3_SecretKey);
                Amazon.S3.Model.DeleteObjectRequest req    = new Amazon.S3.Model.DeleteObjectRequest();
                req.BucketName = AWAPI_File_AmazonS3_BucketName;
                req.Key        = key;

                client.DeleteObject(req);
                return(true);
            }
            catch (Exception)
            {
            }
            return(false);
        }
Ejemplo n.º 35
0
        public bool DeleteFile(string filePath)
        {
            filePath = filePath.Substring(RootUrl.Length);
            string bucketName = filePath.Substring(0, filePath.IndexOf('/'));
            string key = filePath.Substring(bucketName.Length + 1);

            DeleteObjectRequest request = new DeleteObjectRequest()
                .WithBucketName(bucketName)
                .WithKey(key);

            using (AmazonS3 s3 = AWSClientFactory.CreateAmazonS3Client())
            {
                using (DeleteObjectResponse response = s3.DeleteObject(request))
                {
                    return response != null;
                }
            }
        }
Ejemplo n.º 36
0
 public virtual bool DeleteS3File(string awsKey)
 {
     try
     {
         using (IAmazonS3 client = new AmazonS3Client(Configurations.S3AccessKeyID, Configurations.S3SecretKey, RegionEndpoint.USEast1))
         {
             Amazon.S3.Model.DeleteObjectRequest deleteObjectRequest = new Amazon.S3.Model.DeleteObjectRequest
             {
                 BucketName = Configurations.BucketName,
                 Key        = awsKey
             };
             client.DeleteObject(deleteObjectRequest);
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Ejemplo n.º 37
0
        /// <summary>
        /// Deletes file from s3
        /// </summary>
        /// <returns></returns>
        public bool Delete(string fileUrl)
        {
            try
            {
                string key        = fileUrl.Replace(BaseURL, "");
                string bucketName = GetBucketNameFromUrl(fileUrl);

                Amazon.S3.AmazonS3Client client = new Amazon.S3.AmazonS3Client(ConfigurationLibrary.Config.fileAmazonS3AccessKey,
                                                                               ConfigurationLibrary.Config.fileAmazonS3SecreyKey);
                Amazon.S3.Model.DeleteObjectRequest req = new Amazon.S3.Model.DeleteObjectRequest();
                req.BucketName = bucketName;
                req.Key        = key;

                client.DeleteObject(req);
                return(true);
            }
            catch (Exception)
            {
            }
            return(false);
        }
Ejemplo n.º 38
0
        private void EditFile(HttpChallenge httpChallenge, bool delete)
        {
            var filePath = httpChallenge.FilePath;

            // We need to strip off any leading '/' in the path or
            // else it creates a path with an empty leading segment
            if (filePath.StartsWith("/"))
            {
                filePath = filePath.Substring(1);
            }

            using (var s3 = new Amazon.S3.AmazonS3Client(
                       CommonParams.ResolveCredentials(),
                       CommonParams.RegionEndpoint))
            {
                if (delete)
                {
                    var s3Requ = new Amazon.S3.Model.DeleteObjectRequest
                    {
                        BucketName = BucketName,
                        Key        = filePath,
                    };
                    var s3Resp = s3.DeleteObject(s3Requ);
                }
                else
                {
                    var s3Requ = new Amazon.S3.Model.PutObjectRequest
                    {
                        BucketName  = BucketName,
                        Key         = filePath,
                        ContentBody = httpChallenge.FileContent,
                        ContentType = ContentType,
                        CannedACL   = S3CannedAcl,
                    };
                    var s3Resp = s3.PutObject(s3Requ);
                }
            }
        }
Ejemplo n.º 39
0
        async Task <IActionResult> DeleteFile(UploadedFile uploadedFile)
        {
            using (client = new AmazonS3Client(Amazon.RegionEndpoint.USWest1))
            {
                string bucketName = "ed-projects";
                Amazon.S3.Model.DeleteObjectRequest deleteObjectRequest = new Amazon.S3.Model.DeleteObjectRequest
                {
                    BucketName = bucketName,
                    Key        = uploadedFile.SystemFileName
                };

                try
                {
                    await client.DeleteObjectAsync(deleteObjectRequest);

                    return(Ok("File Deleted"));
                }
                catch (AmazonS3Exception s3Exception)
                {
                    Console.WriteLine(s3Exception.Message, s3Exception.InnerException);
                    return(BadRequest(s3Exception));
                }
            }
        }
Ejemplo n.º 40
0
        private Amazon.S3.Model.DeleteObjectResponse CallAWSServiceOperation(IAmazonS3 client, Amazon.S3.Model.DeleteObjectRequest request)
        {
            Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon S3", "DeleteObject");

            try
            {
#if DESKTOP
                return(client.DeleteObject(request));
#elif CORECLR
                return(client.DeleteObjectAsync(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;
            }
        }