本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3Client.deleteObject方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3Client.deleteObject方法的具体用法?Java AmazonS3Client.deleteObject怎么用?Java AmazonS3Client.deleteObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.AmazonS3Client
的用法示例。
在下文中一共展示了AmazonS3Client.deleteObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tearDown
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
final File theFile = new File(TEST_FILE_NAME);
theFile.delete();
if (s3Account != null) {
final AmazonS3Client s3 = new AmazonS3Client(
new BasicAWSCredentials(s3Account.keyId, s3Account.secretKey));
String hash = s3Account.getHashedName();
if (s3.doesBucketExist(hash)) {
for (S3ObjectSummary summary : s3.listObjects(hash).getObjectSummaries()) {
s3.deleteObject(s3Account.getHashedName(), summary.getKey());
}
}
}
super.tearDown();
}
示例2: sendToQueueUsingS3
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
public static String sendToQueueUsingS3(AmazonSQSClient sqs, String queueUrl, AmazonS3Client s3,
String bucketName, Map<String, String> headers, byte[] message,
Func0<String> s3IdFactory) {
Preconditions.checkNotNull(sqs);
Preconditions.checkNotNull(s3);
Preconditions.checkNotNull(queueUrl);
Preconditions.checkNotNull(bucketName);
Preconditions.checkNotNull(message);
String s3Id = s3IdFactory.call();
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(message.length);
for (Entry<String, String> header : headers.entrySet()) {
metadata.setHeader(header.getKey(), header.getValue());
}
s3.putObject(bucketName, s3Id, new ByteArrayInputStream(message), metadata);
try {
sqs.sendMessage(queueUrl, s3Id);
} catch (RuntimeException e) {
try {
s3.deleteObject(bucketName, s3Id);
throw e;
} catch (RuntimeException e2) {
throw new CompositeException(e, e2);
}
}
return s3Id;
}
示例3: deleteObject
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
@Override
public void deleteObject(String bucket, String key) throws Exception
{
RefCountedClient holder = client.get();
AmazonS3Client amazonS3Client = holder.useClient();
try
{
amazonS3Client.deleteObject(bucket, key);
}
finally
{
holder.release();
}
}