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


Java AmazonS3.deleteObject方法代码示例

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


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

示例1: remove

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
public void remove(Object[] params) {
    AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider());
    try {
        s3client.deleteObject(new DeleteObjectRequest(bucketName, params[0].toString()));
    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which " +
            "means your request made it " +
            "to Amazon S3, but was rejected with an error response" +
            " for some reason.");
        System.out.println("Error Message:" + ase.getMessage());
        System.out.println("HTTP Status Code:" + ase.getStatusCode());
        System.out.println("AWS Error Code:" + ase.getErrorCode());
        System.out.println("Error Type:" + ase.getErrorType());
        System.out.println("Request ID:" + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which " +
            "means the client encountered " +
            "an internal error while trying to " +
            "communicate with S3, " +
            "such as not being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }

}
 
开发者ID:EventHorizon27,项目名称:dataset-lib,代码行数:25,代码来源:S3Provider.java

示例2: emptyBucketWithPrefix

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
public static void emptyBucketWithPrefix(String bucket, String prefix) {
    AmazonS3 s3Client = AmazonS3Provider.getS3Client();

    List<S3ObjectSummary> files = Commons.getBucketObjectSummaries(bucket, prefix);

    for (S3ObjectSummary object : files)
        s3Client.deleteObject(object.getBucketName(), object.getKey());
}
 
开发者ID:d2si-oss,项目名称:ooso,代码行数:9,代码来源:Commons.java

示例3: deleteObject

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
/**
 * Delete object
 * @param object name/key of the object to be deleted
 */
@PublicAtsApi
public void deleteObject( String objectName ) {

    AmazonS3 s3Client = getClient();
    s3Client.deleteObject(bucketName, objectName);
    LOG.info("Deleted object '" + objectName + "' from bucket '" + bucketName + "'");
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:12,代码来源:S3Operations.java

示例4: move

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
/**
 * Move or rename file from one bucket to another
 *
 * @param fromBucket the bucket name, where the file is currently located
 * @param toBucket the bucket name, where the file will be moved
 * @param file the name of the file, that will be moved
 */
@PublicAtsApi
public void move( String fromBucket, String toBucket, String file ) {

    AmazonS3 s3Client = getClient();

    try {
        s3Client.copyObject(fromBucket, file, toBucket, file);
        s3Client.deleteObject(fromBucket, file);
    } catch (Exception e) {
        handleExeption(e, "S3 object move error");
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:20,代码来源:S3Operations.java

示例5: sendToQueueUsingS3

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
public static String sendToQueueUsingS3(AmazonSQS sqs, String queueUrl, AmazonS3 s3, String bucketName,
        Map<String, String> headers, byte[] message, Callable<String> s3IdFactory) {
    Preconditions.checkNotNull(sqs);
    Preconditions.checkNotNull(s3);
    Preconditions.checkNotNull(queueUrl);
    Preconditions.checkNotNull(bucketName);
    Preconditions.checkNotNull(message);
    String s3Id;
    try {
        s3Id = s3IdFactory.call();
    } catch (final Exception e1) {
        throw new RuntimeException(e1);
    }
    final ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(message.length);
    for (final 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 (final RuntimeException e) {
        try {
            s3.deleteObject(bucketName, s3Id);
            throw e;
        } catch (final RuntimeException e2) {
            throw new io.reactivex.exceptions.CompositeException(e, e2);
        }
    }
    return s3Id;
}
 
开发者ID:davidmoten,项目名称:rxjava2-aws,代码行数:32,代码来源:Sqs.java

示例6: handleRequest

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
@Override
public Parameters handleRequest(Parameters parameters, Context context) {

    context.getLogger().log("Input Function [" + context.getFunctionName() + "], Parameters [" + parameters + "]");

    // The archive location of the snapshot will be decided by the alert
    // flag
    String newFilename;
    if (parameters.getSendAlert()) {
        newFilename = parameters.getS3Key().replace("upload/", "archive/alerts/");
    } else {
        newFilename = parameters.getS3Key().replace("upload/", "archive/falsepositives/");
    }

    // Ensure that the first two hyphens are used to create sub-directories
    // in the file path
    newFilename = newFilename.replaceFirst("-", "/");
    newFilename = newFilename.replaceFirst("-", "/");

    // Using the S3 client, first copy the file to the archive, and then
    // delete the original
    AmazonS3 client = AmazonS3ClientBuilder.defaultClient();
    CopyObjectRequest copyObjectRequest = new CopyObjectRequest(parameters.getS3Bucket(), parameters.getS3Key(), parameters.getS3Bucket(), newFilename);
    client.copyObject(copyObjectRequest);
    DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(parameters.getS3Bucket(), parameters.getS3Key());
    client.deleteObject(deleteObjectRequest);

    // Place the new location in the parameters
    parameters.setS3ArchivedKey(newFilename);

    context.getLogger().log("Output Function [" + context.getFunctionName() + "], Parameters [" + parameters + "]");

    return parameters;
}
 
开发者ID:markwest1972,项目名称:smart-security-camera,代码行数:35,代码来源:S3ArchiveImageHandler.java


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