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


C# AmazonS3.DeleteObject方法代码示例

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


在下文中一共展示了AmazonS3.DeleteObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: Main

        public static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            log.Info("Initializing and connecting to AWS...");

            s3 = AWSClientFactory.CreateAmazonS3Client(RegionEndpoint.USWest1);
            indexer = new FileIndexer("Files");
            indexer.Index();

            s3indexer = new S3Indexer(Settings.Default.BucketName, Settings.Default.FolderName, "S3Tmp", s3);
            s3indexer.Index();

            log.Info("Comparing local index and remote index.");

            var filesToUpload = (from filePair in indexer.FileIndex where !s3indexer.HashedFiles.ContainsKey(filePair.Key) || !s3indexer.HashedFiles[filePair.Key].SequenceEqual(filePair.Value) select filePair.Key).ToList();
            var filesToDelete = (from filePair in s3indexer.HashedFiles where !indexer.FileIndex.ContainsKey(filePair.Key) select filePair.Key).ToList();

            foreach(var fileDelete in filesToDelete)
            {
                log.Debug("Deleting file "+fileDelete);
                s3.DeleteObject(new DeleteObjectRequest()
                                    {
                                        BucketName = Settings.Default.BucketName,
                                        Key = Settings.Default.FolderName + "/" + fileDelete
                                    });
            }

            foreach(var fileUpload in filesToUpload)
            {
                log.Debug("Uploading file "+fileUpload);
                s3.PutObject(new PutObjectRequest()
                                 {
                                     BucketName = Settings.Default.BucketName,
                                     Key = Settings.Default.FolderName + "/" + fileUpload,
                                     AutoCloseStream = true,
                                     InputStream = new FileStream("Files/" + fileUpload, FileMode.Open)
                                 });
            }

            log.Info("Re-indexing files...");

            using (MemoryStream stream = new MemoryStream())
            {
                Serializer.Serialize(stream, indexer.FileIndex);
                stream.Position = 0;
                s3.PutObject(new PutObjectRequest()
                {
                    BucketName = Settings.Default.BucketName,
                    Key = Settings.Default.FolderName + "/" + "index.mhash",
                    InputStream = stream
                });
            }

            log.Info("Done!");

            Console.Read();
        }
开发者ID:paralin,项目名称:S3FolderSync,代码行数:57,代码来源:Program.cs

示例4: Delete

        public void Delete(string fileName)
        {
            string uniqueKeyItemName = string.Format("{0}-{1}", keyName, fileName);
            DeleteObjectRequest deleteObjectRequest =
             new DeleteObjectRequest()
             .WithBucketName(bucketName)
             .WithKey(uniqueKeyItemName );

            using (client = new AmazonS3Client(accessKeyID, secretAccessKeyID))
            {
                try
                {
                    client.DeleteObject(deleteObjectRequest);
                }
                catch (AmazonS3Exception s3Exception)
                {
                    throw new Exception( String.Format("Error Occurred in Delete operation for ObjectKeyID: {0}", uniqueKeyItemName ),s3Exception);
                }
            }
        }
开发者ID:TellagoDevLabs,项目名称:CloudPoint,代码行数:20,代码来源:AmazonS3AssetStorageManager.cs

示例5: deleteFile

        private void deleteFile(bool hasFile, string fileType, int id)
        {
            if (hasFile)
            {
                DeleteObjectRequest request = new DeleteObjectRequest();
                request.WithBucketName("intelrecruiter");

                ListObjectsRequest listObjReq = new ListObjectsRequest();
                listObjReq.WithBucketName("intelrecruiter")
                    .WithPrefix(fileType + "/" + id.ToString());
                using (client = Amazon.AWSClientFactory.CreateAmazonS3Client("AKIAJ47VSG7WMA62WLCA", "3tqlHujlftpk6j/z5OtDw2eg9N2FJtz1RwL8bEa3"))
                {
                    var results = client.ListObjects(listObjReq).S3Objects;
                    foreach (var obj in results)
                    {
                        request.Key = obj.Key;
                        client.DeleteObject(request);
                    }
                }
            }
        }
开发者ID:nnennaude,项目名称:recruiter-web,代码行数:21,代码来源:ResumesController.cs

示例6: DeleteObject

 private static void DeleteObject(AmazonS3 s3Client, string bucket, string key)
 {
     var deleteObjectRequest = new DeleteObjectRequest().WithBucketName(bucket).WithKey(key);
       s3Client.DeleteObject(deleteObjectRequest);
 }
开发者ID:nrazon,项目名称:S3Emulator,代码行数:5,代码来源:Program.cs


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