本文整理汇总了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);
}
示例2: DeleteFile
public static void DeleteFile(AmazonS3 Client, string filekey)
{
DeleteObjectRequest request = new DeleteObjectRequest()
{
BucketName = BUCKET_NAME,
Key = filekey
};
S3Response response = Client.DeleteObject(request);
}
示例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();
}
示例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);
}
}
}
示例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);
}
}
}
}
示例6: DeleteObject
private static void DeleteObject(AmazonS3 s3Client, string bucket, string key)
{
var deleteObjectRequest = new DeleteObjectRequest().WithBucketName(bucket).WithKey(key);
s3Client.DeleteObject(deleteObjectRequest);
}