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


C# Model.DeleteObjectRequest类代码示例

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


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

示例1: DeleteFile

        // 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;
                        }
                    }

                }
        }
开发者ID:dbows,项目名称:MVCAssetManager,代码行数:51,代码来源:AmazonTransferHandler.ashx.cs

示例2: DeleteFile

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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: TestCleanup

        public void TestCleanup()
        {
            var deleteRequest = new DeleteObjectRequest()
                .WithBucketName(bucket.BucketName)
                .WithKey(this.objKey);

            using (var deleteResponse = client.DeleteObject(deleteRequest)) { }
        }
开发者ID:pbutlerm,项目名称:dataservices-sdk-dotnet,代码行数:8,代码来源:UpdateObjectTests.cs

示例8: ProcessRecord

 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);
 }
开发者ID:ksikes,项目名称:Amazon.Powershell,代码行数:9,代码来源:DeleteObjectCmdlet.cs

示例9: DeleteS3Object

 private static void DeleteS3Object(string key)
 {
     DeleteObjectRequest deleteRequest = new DeleteObjectRequest
                                             {
                                                 BucketName = BucketName,
                                                 Key = key
                                             };
     _amazonS3Client.DeleteObject(deleteRequest);
 }
开发者ID:kakaruto,项目名称:S3Sync,代码行数:9,代码来源:Program.cs

示例10: DeleteItemAsync

 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);
 }
开发者ID:bvanschy,项目名称:SourceControlSync,代码行数:9,代码来源:DeleteItemCommand.cs

示例11: DeleteFile

 public static void DeleteFile(AmazonS3 Client, string filekey)
 {
     DeleteObjectRequest request = new DeleteObjectRequest()
     {
         BucketName = BUCKET_NAME,
         Key = filekey
     };
     S3Response response = Client.DeleteObject(request);
 }
开发者ID:xescrp,项目名称:breinstormin,代码行数:9,代码来源:S3Engine.cs

示例12: StateDelete

        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);
        }
开发者ID:kohashi,项目名称:photon.webhooks.turnbased.waws,代码行数:10,代码来源:Amazon.cs

示例13:

 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);
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:10,代码来源:AmazonS3Client.Extensions.cs

示例14: Delete

 //Deletes a file
 public void Delete(string fileName)
 {
     IAmazonS3 client = GetS3Client();
     var request = new DeleteObjectRequest
     {
         BucketName = _BucketName,
         Key = _Prefix + fileName
     };
     client.DeleteObject(request);
 }
开发者ID:jamesdarragh,项目名称:basic-file-upload,代码行数:11,代码来源:FileService.cs

示例15: 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


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