• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Model.DeleteObjectRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ExecuteS3Task

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


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


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


示例19: Delete

 /// <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();
         }
     }
 }
开发者ID:andersgranberg,项目名称:BrickPile,代码行数:14,代码来源:AmazonS3VirtualFile.cs


示例20: Delete

        public bool Delete(string key)
        {
            DeleteObjectRequest request = new DeleteObjectRequest
            {
                BucketName = Bucket,
                Key = key
            };

            var response = S3Client.DeleteObject(request);

            return response.HttpStatusCode == HttpStatusCode.NoContent;
        }
开发者ID:aluitink,项目名称:Ojibwe,代码行数:12,代码来源:AmazonS3Adapter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Model.GetObjectMetadataRequest类代码示例发布时间:2022-05-24
下一篇:
C# Model.CopyObjectRequest类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap