List of usage examples for com.amazonaws AmazonServiceException AmazonServiceException
public AmazonServiceException(String errorMessage, Exception cause)
From source file:edu.si.services.beans.cameratrap.AmazonS3ClientMock.java
License:Apache License
@SuppressWarnings("resource") @Override/*from ww w.j a v a 2 s . c om*/ public PutObjectResult putObject(PutObjectRequest putObjectRequest) throws AmazonClientException, AmazonServiceException { putObjectRequests.add(putObjectRequest); S3Object s3Object = new S3Object(); s3Object.setBucketName(putObjectRequest.getBucketName()); s3Object.setKey(putObjectRequest.getKey()); if (putObjectRequest.getFile() != null) { try { s3Object.setObjectContent(new FileInputStream(putObjectRequest.getFile())); } catch (FileNotFoundException e) { throw new AmazonServiceException("Cannot store the file object.", e); } } else { s3Object.setObjectContent(putObjectRequest.getInputStream()); } objects.add(s3Object); PutObjectResult putObjectResult = new PutObjectResult(); putObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264"); return putObjectResult; }
From source file:org.kuali.maven.wagon.S3Wagon.java
License:Educational Community License
/** * Create a PutObjectRequest based on the source file and destination passed in *///from w ww . ja v a 2s. co m protected PutObjectRequest getPutObjectRequest(File source, String destination, TransferProgress progress) { try { String key = getNormalizedKey(source, destination); String bucketName = bucket.getName(); InputStream input = getInputStream(source, progress); ObjectMetadata metadata = getObjectMetadata(source, destination); PutObjectRequest request = new PutObjectRequest(bucketName, key, input, metadata); request.setCannedAcl(acl); return request; } catch (FileNotFoundException e) { throw new AmazonServiceException("File not found", e); } }
From source file:org.weakref.s3fs.util.AmazonS3ClientMock.java
License:Apache License
@Override public PutObjectResult putObject(String bucketName, String key, File file) throws AmazonClientException, AmazonServiceException { try {//w w w.j a va 2s . co m ByteArrayInputStream stream = new ByteArrayInputStream(Files.readAllBytes(file.toPath())); S3Element elem = parse(stream, bucketName, key); objects.get(find(bucketName)).add(elem); PutObjectResult putObjectResult = new PutObjectResult(); putObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264"); return putObjectResult; } catch (IOException e) { throw new AmazonServiceException("", e); } }