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


C# DeleteObjectRequest.WithBucketName方法代码示例

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


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

示例1: PhysicallyDeletePhoto

        public static S3Response PhysicallyDeletePhoto(AmazonS3 anS3Client, string aBucketName, string aFileName)
        {
            DeleteObjectRequest myDeleteRequest = new DeleteObjectRequest();
            myDeleteRequest.WithBucketName(aBucketName).WithKey(aFileName);

            return anS3Client.DeleteObject(myDeleteRequest);
        }
开发者ID:henryksarat,项目名称:Have-A-Voice,代码行数:7,代码来源:AWSPhotoHelper.cs

示例2: DeleteDocument

        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));
                }
            }
        }
开发者ID:parm-ameotech,项目名称:amazon-bucket-management,代码行数:28,代码来源:AmazonService.cs

示例3: DeleteImageFile

    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";
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:27,代码来源:AmazonS3.cs

示例4: DeletingAnObject

 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();
 }
开发者ID:dbows,项目名称:MVCAssetManager,代码行数:8,代码来源:Helpers.cs

示例5: RemoveFileFromBucket

 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();
 }
开发者ID:uxsniper,项目名称:NeuReg,代码行数:10,代码来源:UtilityHelper.cs

示例6: DeletingObject

        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);
            }
        }
开发者ID:ahmetoz,项目名称:Photopia,代码行数:11,代码来源:AmazonS3Service.cs

示例7: DeleteFile

        /// <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();
        }
开发者ID:orcareih,项目名称:AST-Amazon-S3,代码行数:16,代码来源:AmazonS3FileSystem.cs

示例8: DeleteFile

 public static bool DeleteFile(string name)
 {
     try
     {
         DeleteObjectRequest request = new DeleteObjectRequest();
         request.WithBucketName(BucketName)
             .WithKey(name);
         AmazonS3Config config = new AmazonS3Config();
         config.CommunicationProtocol = Protocol.HTTP;
         using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(AccessKeyID, SecretAccessKeyID, config))
         using (DeleteObjectResponse response = client.DeleteObject(request))
         {
             if (response != null)
                 return true;
             else
                 return false;
         }
     }
     catch (AmazonS3Exception amazonS3Exception)
     {
     #if(DEBUG)
         if (amazonS3Exception.ErrorCode != null &&
             (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||
             amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
         {
             Console.WriteLine("Please check the provided AWS Credentials.");
             Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
         }
         else
         {
             Console.WriteLine("An error occurred with the message '{0}' when deleting an object", amazonS3Exception.Message);
         }
     #endif
         return false;
     }
     catch (Exception e)
     {
         return false;
     }
 }
开发者ID:davemurphysf,项目名称:PhoneAGram,代码行数:40,代码来源:AmazonS3Helper.cs

示例9: DeleteImage

        /// <summary>
        /// Delete the specified image
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="fileName"></param>
        public override void DeleteImage(string filePath, string key)
        {
            DeleteObjectRequest request = new DeleteObjectRequest();

            request.WithBucketName("images.climbfind.com" + filePath)
                .WithKey(key);

            using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(Stgs.AWSAccessKey, Stgs.AWSSecretKey, S3Config))
            {
                // simple object put
                using (DeleteObjectResponse response = client.DeleteObject(request))
                {
                    //-- Do a little bit of tracing
                    string headersString = string.Empty;
                    WebHeaderCollection headers = response.Headers;
                    foreach (string h in headers.Keys)
                    {
                        headersString += string.Format("Response Header: {0}, Value: {1}", h, headers.Get(h));
                    }
                    CfTrace.Information(TraceCode.DeletingImage, headersString);
                }
            }
        }
开发者ID:jkresner,项目名称:Climbfind_v4_2011,代码行数:28,代码来源:AwsS3ImagePersister.cs

示例10: DeleteS3Object

    public string DeleteS3Object(string Bucket, string key)
    {
        string AWSAccessKey = ConfigurationManager.AppSettings["AWSAccessKey"];
        string AWSSecretKey = ConfigurationManager.AppSettings["AWSSecretKey"];
        TransferUtility transferUtility = new TransferUtility(AWSAccessKey, AWSSecretKey);
        try
        {
            DeleteObjectRequest request = new DeleteObjectRequest();
             request.WithBucketName(Bucket)
                .WithKey(key);
            using (DeleteObjectResponse response = transferUtility.S3Client.DeleteObject(request))
            {
                WebHeaderCollection headers = response.Headers;
             }
        }
        catch (AmazonS3Exception ex)
        {
           return ex.Message + ": " + ex.StackTrace;
        }

        return "OK";
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:22,代码来源:AmazonS3.cs

示例11: Delete

 public void Delete(string key)
 {
     var deleteObject = new DeleteObjectRequest();
     deleteObject.WithBucketName(this._bucketName).WithKey(key);
     this._client.DeleteObject(deleteObject);
 }
开发者ID:ajuris,项目名称:opensource,代码行数:6,代码来源:AmazonS3Repository.cs

示例12: JSONDeleteAWSFile

        public JsonResult JSONDeleteAWSFile(string key)
        {
            var request = new DeleteObjectRequest();

            request.WithBucketName(AWSBucket)
                   .WithKey(key);

            using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey))
            {
                using (DeleteObjectResponse response = client.DeleteObject(request)) { }
            }

            return Json(null);
        }
开发者ID:aherrick,项目名称:AmazonAWS-CRD,代码行数:14,代码来源:HomeController.cs

示例13: DeleteFile

        public void DeleteFile(string path)
        {
            using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey, _S3Config))
            {
                DeleteObjectRequest request = new DeleteObjectRequest();
                request.WithBucketName(BucketName)
                    .WithKey(path);
                using (DeleteObjectResponse response = client.DeleteObject(request))
                {

                }
            }
        }
开发者ID:jonparker,项目名称:Orchard,代码行数:13,代码来源:S3StorageProvider.cs

示例14: DeleteFolder

        public void DeleteFolder(string path)
        {
            //TODO: recursive on all keys with prefix
            using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey, _S3Config))
            {
                DeleteObjectRequest request = new DeleteObjectRequest();
                request.WithBucketName(BucketName)
                    .WithKey(path);
                using (DeleteObjectResponse response = client.DeleteObject(request))
                {

                }
            }
        }
开发者ID:jonparker,项目名称:Orchard,代码行数:14,代码来源:S3StorageProvider.cs

示例15: DeletingAWS

        public ActionResult DeletingAWS(string keyName)
        {
            if (!checkRequiredFields())
            {
                ViewBag.Result = "";
                return View();
            }
            try
            {

                DeleteObjectRequest request = new DeleteObjectRequest();
                request.WithBucketName(bucketName)
                    .WithKey(keyName);
                AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(RegionEndpoint.APSoutheast1);
                DeleteObjectResponse response = client.DeleteObject(request);

                //using (DeleteObjectResponse response = client.DeleteObject(request))
                //{
                //    WebHeaderCollection headers = response.Headers;
                //    foreach (string key in headers.Keys)
                //    {
                //        Console.WriteLine("Response Header: {0}, Value: {1}", key, headers.Get(key));
                //    }
                //}
            }
            catch (AmazonS3Exception amazonS3Exception)
            {
                if (amazonS3Exception.ErrorCode != null &&
                    (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||
                    amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
                {
                    Console.WriteLine("Please check the provided AWS Credentials.");
                    Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
                }
                else
                {
                    Console.WriteLine("An error occurred with the message '{0}' when deleting an object", amazonS3Exception.Message);
                }

                NotificationHandler.setNotification(NotificationHandler.NOTY_ERROR, "Error removing the file from our File System, this file record is now removed");
            }
            return View("Refresh");
        }
开发者ID:jofrysutanto,项目名称:StormWeb,代码行数:43,代码来源:DocumentController.cs


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