本文整理汇总了C#中IAmazonS3.DeleteObjectAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IAmazonS3.DeleteObjectAsync方法的具体用法?C# IAmazonS3.DeleteObjectAsync怎么用?C# IAmazonS3.DeleteObjectAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAmazonS3
的用法示例。
在下文中一共展示了IAmazonS3.DeleteObjectAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteMessage
private void DeleteMessage(IAmazonSQS sqs,
IAmazonS3 s3,
Message message,
SqsTransportMessage sqsTransportMessage,
TransportMessage transportMessage)
{
sqs.DeleteMessage(_queueUrl, message.ReceiptHandle);
if (!String.IsNullOrEmpty(sqsTransportMessage.S3BodyKey))
{
// Delete the S3 body asynchronously.
// We don't really care too much if this call succeeds or fails - if it fails,
// the S3 bucket lifecycle configuration will eventually delete the message anyway.
// So, we can get better performance by not waiting around for this call to finish.
var s3DeleteTask = s3.DeleteObjectAsync(
new DeleteObjectRequest
{
BucketName = ConnectionConfiguration.S3BucketForLargeMessages,
Key = ConnectionConfiguration.S3KeyPrefix + transportMessage.Id
});
s3DeleteTask.ContinueWith(t =>
{
if (t.Exception != null)
{
// If deleting the message body from S3 fails, we don't
// want the exception to make its way through to the _endProcessMessage below,
// as the message has been successfully processed and deleted from the SQS queue
// and effectively doesn't exist anymore.
// It doesn't really matter, as S3 is configured to delete message body data
// automatically after a certain period of time.
Logger.Warn("Couldn't delete message body from S3. Message body data will be aged out at a later time.", t.Exception);
}
});
}
}