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


Java DeleteObjectRequest类代码示例

本文整理汇总了Java中com.amazonaws.services.s3.model.DeleteObjectRequest的典型用法代码示例。如果您正苦于以下问题:Java DeleteObjectRequest类的具体用法?Java DeleteObjectRequest怎么用?Java DeleteObjectRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeleteObjectRequest类属于com.amazonaws.services.s3.model包,在下文中一共展示了DeleteObjectRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: remove

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的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: delete

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public boolean delete(String hostName, Path path, boolean recursive) throws IOException {
  String obj = path.toString();
  if (path.toString().startsWith(hostName)) {
    obj = path.toString().substring(hostName.length());
  }
  LOG.debug("Object name to delete {}. Path {}", obj, path.toString());
  try {
    mClient.deleteObject(new DeleteObjectRequest(mBucket, obj));
    memoryCache.removeFileStatus(path.toString());
    return true;
  } catch (AmazonServiceException e) {
    if (e.getStatusCode() != 404) {
      throw new IOException(e);
    }
  }
  LOG.warn("Delete on {} not found. Nothing to delete");
  return false;
}
 
开发者ID:SparkTC,项目名称:stocator,代码行数:20,代码来源:COSAPIClient.java

示例3: delete

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public void delete(ContentReference contentReference) throws ContentIOException
{
    if (!isContentReferenceSupported(contentReference))
    {
        throw new ContentIOException("ContentReference not supported");
    }
    
    String remotePath = getRelativePath(contentReference.getUri());
    
    try
    {
        s3.deleteObject(new DeleteObjectRequest(s3BucketName, remotePath));
    } catch (AmazonClientException e)
    {
        throw new ContentIOException("Failed to delete content", e);
    }
    
}
 
开发者ID:Alfresco,项目名称:gytheio,代码行数:20,代码来源:S3ContentReferenceHandlerImpl.java

示例4: remove

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public void remove(final String key) throws IOException {
    try {
        final AmazonS3 aws = this.regn.aws();
        final long start = System.currentTimeMillis();
        aws.deleteObject(new DeleteObjectRequest(this.bkt, key));
        Logger.info(
            this,
            "ocket '%s' removed in bucket '%s' in %[ms]s",
            key, this.bkt, System.currentTimeMillis() - start
        );
    } catch (final AmazonServiceException ex) {
        throw new IOException(
            String.format(
                "failed to remove '%s' bucket",
                this.bkt
            ),
            ex
        );
    }
}
 
开发者ID:jcabi,项目名称:jcabi-s3,代码行数:22,代码来源:AwsBucket.java

示例5: delete

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
/**
 * Delete file from Amazon S3 storage.
 * 
 * @param bucket
 *            - S3 Bucket name.
 * @param key
 *            - S3 storage path. Example:
 *            DEMO/TestSuiteName/TestMethodName/file.txt
 */
public void delete(String bucket, String key) {
	if (key == null) {
		throw new RuntimeException("Key is null!");
	}
	if (key.isEmpty()) {
		throw new RuntimeException("Key is empty!");
	}

	try {
		s3client.deleteObject(new DeleteObjectRequest(bucket, key));
	} catch (AmazonServiceException ase) {
		LOGGER.error("Caught an AmazonServiceException, which "
				+ "means your request made it "
				+ "to Amazon S3, but was rejected with an error response for some reason.\n"
				+ "Error Message:    " + ase.getMessage() + "\n"
				+ "HTTP Status Code: " + ase.getStatusCode() + "\n"
				+ "AWS Error Code:   " + ase.getErrorCode() + "\n"
				+ "Error Type:       " + ase.getErrorType() + "\n"
				+ "Request ID:       " + ase.getRequestId());
	} catch (AmazonClientException ace) {
		LOGGER.error("Caught an AmazonClientException.\n"
				+ "Error Message: " + ace.getMessage());
	}
}
 
开发者ID:qaprosoft,项目名称:carina,代码行数:34,代码来源:AmazonS3Manager.java

示例6: deleteObject

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public void deleteObject(DeleteObjectRequest deleteObjectRequest)
        throws AmazonClientException, AmazonServiceException {
    String blobName = deleteObjectRequest.getKey();

    if (!blobs.containsKey(blobName)) {
        throw new AmazonS3Exception("[" + blobName + "] does not exist.");
    }

    blobs.remove(blobName);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:MockAmazonS3.java

示例7: handleRequest

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的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

示例8: deleteObject

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public void deleteObject(DeleteObjectRequest deleteObjectRequest)
        throws SdkClientException, AmazonServiceException {
    deleteObjectRequest = beforeClientExecution(deleteObjectRequest);
    rejectNull(deleteObjectRequest,
        "The delete object request must be specified when deleting an object");

    rejectNull(deleteObjectRequest.getBucketName(), "The bucket name must be specified when deleting an object");
    rejectNull(deleteObjectRequest.getKey(), "The key must be specified when deleting an object");

    Request<DeleteObjectRequest> request = createRequest(deleteObjectRequest.getBucketName(), deleteObjectRequest.getKey(), deleteObjectRequest, HttpMethodName.DELETE);
    invoke(request, voidResponseHandler, deleteObjectRequest.getBucketName(), deleteObjectRequest.getKey());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:AmazonS3Client.java

示例9: deleteObject

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public void deleteObject(DeleteObjectRequest req) {
    req.getRequestClientOptions().appendUserAgent(USER_AGENT);
    // Delete the object
    super.deleteObject(req);
    // If it exists, delete the instruction file.
    InstructionFileId ifid = new S3ObjectId(req.getBucketName(), req.getKey()).instructionFileId();

    DeleteObjectRequest instructionDeleteRequest = (DeleteObjectRequest) req.clone();
    instructionDeleteRequest.withBucketName(ifid.getBucket()).withKey(ifid.getKey());
    super.deleteObject(instructionDeleteRequest);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:13,代码来源:AmazonS3EncryptionClient.java

示例10: removeAllObjects

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
private void removeAllObjects() {
    amazonS3.listObjects(bucketName)
            .getObjectSummaries()
            .forEach(s3ObjectSummary -> {
                DeleteObjectRequest request = new DeleteObjectRequest(bucketName, s3ObjectSummary.getKey());
                amazonS3.deleteObject(request);
            });
}
 
开发者ID:julianghionoiu,项目名称:tdl-auth,代码行数:9,代码来源:RemoteTestBucket.java

示例11: delete

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public void delete(String path) throws BusinessException {
    if (!Optional.ofNullable(path).isPresent()) {
        throw new BusinessException(Validations.INVALID_PATH.getCode());
    }
    client.getClient(credentials.getCredentials());
    try {
        s3Client.deleteObject(
                new DeleteObjectRequest(cdnConfig.getName(), path)
        );
    } catch (AmazonServiceException e) {
        throw new BusinessException(e.getMessage());
    }
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:15,代码来源:AwsUploadRepository.java

示例12: moveObject

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public CompletableFuture<Void> moveObject(String fromBucketName, String fromKey, String toBucketName,
        String toKey) {
    CopyObjectRequest copyObjectResult
        = new CopyObjectRequest(fromBucketName, fromKey, toBucketName, toKey);
    DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(fromBucketName, fromKey);
    return CompletableFuture.runAsync(
        () -> {
            s3Client.copyObject(copyObjectResult);
            s3Client.deleteObject(deleteObjectRequest);
        },
        executorService
    );
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:15,代码来源:S3ConnectionImpl.java

示例13: deleteBySha1

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
@Override
public void deleteBySha1(final String tenant, final String sha1Hash) {
    final String key = objectKey(tenant, sha1Hash);

    LOG.info("Deleting S3 object from bucket {} and key {}", s3Properties.getBucketName(), key);
    amazonS3.deleteObject(new DeleteObjectRequest(s3Properties.getBucketName(), key));
}
 
开发者ID:eclipse,项目名称:hawkbit-extensions,代码行数:8,代码来源:S3Repository.java

示例14: deleteObject

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
public void deleteObject(AWSCredentials awsCredentials, String region, String bucket, String key) {
    try {
        runtimeCredentialsProvider.setAwsCredentials(awsCredentials);
        amazonS3.setRegion(Region.getRegion(Regions.fromName(region)));
        amazonS3.deleteObject(new DeleteObjectRequest(bucket, key));
    } catch (AmazonClientException e) {
        throw new OmakaseRuntimeException(e);
    }
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:10,代码来源:S3Client.java

示例15: copy

import com.amazonaws.services.s3.model.DeleteObjectRequest; //导入依赖的package包/类
static void copy(
    AmazonS3 s3Client,
    String srcBucket,
    String sourceKey,
    String destBucket,
    String destKey,
    boolean isMove
) {
  CopyObjectRequest cp = new CopyObjectRequest(srcBucket, sourceKey, destBucket, destKey);
  s3Client.copyObject(cp);
  if (isMove) {
    s3Client.deleteObject(new DeleteObjectRequest(srcBucket, sourceKey));
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:15,代码来源:AmazonS3Util.java


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