@Override public ObjectMetadata getObjectMetadata(String bucketName, String key) throws SdkClientException, AmazonServiceException { return getObjectMetadata(new GetObjectMetadataRequest(bucketName, key)); }
@Override public boolean doesObjectExist(String bucketName, String objectName) throws AmazonServiceException, SdkClientException { try { getObjectMetadata(bucketName, objectName); return true; } catch (AmazonS3Exception e) { if (e.getStatusCode() == 404) { return false; } throw e; } }
@Override public ObjectMetadata getObjectMetadata(String bucket, String key) throws Exception { RefCountedClient holder = client.get(); AmazonS3Client amazonS3Client = holder.useClient(); try { return amazonS3Client.getObjectMetadata(bucket, key); } finally { holder.release(); } }
s3.getObjectMetadata(pointsetBucket, pointSetId + ".json.gz"); } catch (AmazonServiceException e) {
@Override @Nullable protected ObjectStatus getObjectStatus(String key) throws IOException { try { ObjectMetadata meta = mClient.getObjectMetadata(mBucketName, key); return new ObjectStatus(key, meta.getETag(), meta.getContentLength(), meta.getLastModified().getTime()); } catch (AmazonServiceException e) { if (e.getStatusCode() == 404) { // file not found, possible for exists calls return null; } throw new IOException(e); } catch (AmazonClientException e) { throw new IOException(e); } }
@Override public ObjectMetadata getObjectMetadata(String bucketName, String key) throws AmazonClientException, AmazonServiceException { return getObjectMetadata(new GetObjectMetadataRequest(bucketName, key)); }
@Override public boolean doesObjectExist(String bucketName, String objectName) throws AmazonServiceException, AmazonClientException { try { getObjectMetadata(bucketName, objectName); return true; } catch (final AmazonS3Exception e) { if (e.getStatusCode() == 404) { return false; } throw e; } }
@Override protected boolean doesRemoteResourceExist(final String resourceName) { try { client.getObjectMetadata(bucketName, basedir + resourceName); } catch (AmazonClientException e) { return false; } return true; }
public Long getObjectSize(AmazonS3Client amazonS3Client, String bucket, String key) throws IOException { return amazonS3Client.getObjectMetadata(bucket, key).getContentLength(); }
@Override public ObjectMetadata getObjectMetadata(String bucketName, String key) throws SdkClientException, AmazonServiceException { return getObjectMetadata(new GetObjectMetadataRequest(bucketName, key)); }
/** * Is the S3 object newer than the timestamp passed in? */ @Override protected boolean isRemoteResourceNewer(final String resourceName, final long timestamp) { ObjectMetadata metadata = client.getObjectMetadata(bucketName, basedir + resourceName); return metadata.getLastModified().compareTo(new Date(timestamp)) < 0; }
@Override public ObjectMetadata getObjectMetadata(String bucketName, String key) throws AmazonClientException, AmazonServiceException { return getObjectMetadata(new GetObjectMetadataRequest(bucketName, key)); }
private ObjectMetadata getMetadata(String fullPath) { final String relativePath = mounter.getMountRelativePath(fullPath, mountPoint); final String s3path = getS3path(relativePath); final ObjectMetadata metadata; try { metadata = client.getObjectMetadata(s3bucket, s3path); } catch(AmazonServiceException e) { return null; } return metadata; }
private void throwIfContentNotExist(String bucketName, String contentId) { try { s3Client.getObjectMetadata(bucketName, contentId); } catch (AmazonClientException e) { String err = "Could not find content item with ID " + contentId + " in S3 bucket " + bucketName + ". S3 error: " + e.getMessage(); throw new NotFoundException(err); } }
@Nullable public ObjectMetadata getObjectMetadata(String key) throws StorageException { ObjectMetadata obj = null; try { obj = conn.getObjectMetadata(bucketName, key); } catch (AmazonS3Exception e) { if (404 != e.getStatusCode()) { // 404 == not found throw new StorageException( "Error checking existence of " + key + ": " + e.getMessage(), e); } } return obj; }
@Override public String getExtractedText(BinaryValue binaryValue) throws BinaryStoreException { try { String key = binaryValue.getKey().toString(); ObjectMetadata metadata = s3Client.getObjectMetadata(bucketName, key); return metadata.getUserMetadata().get(EXTRACTED_TEXT_KEY); } catch (AmazonClientException e) { throw new BinaryStoreException(e); } }
@Override public String getExtractedText(BinaryValue binaryValue) throws BinaryStoreException { try { String key = binaryValue.getKey().toString(); ObjectMetadata metadata = s3Client.getObjectMetadata(bucketName, key); return metadata.getUserMetadata().get(EXTRACTED_TEXT_KEY); } catch (AmazonClientException e) { throw new BinaryStoreException(e); } }
private ObjectMetadata getObjectDetails(String bucketName, String contentId, boolean retry) { try { return s3Client.getObjectMetadata(bucketName, contentId); } catch (AmazonClientException e) { throwIfContentNotExist(bucketName, contentId); String err = "Could not get details for content " + contentId + " in S3 bucket " + bucketName + " due to error: " + e.getMessage(); throw new StorageException(err, e, retry); } }
@Override protected String getStoredMimeType(BinaryValue binaryValue) throws BinaryStoreException { try { String key = binaryValue.getKey().toString(); ObjectMetadata metadata = s3Client.getObjectMetadata(bucketName, key); return metadata.getContentType(); } catch (AmazonClientException e) { throw new BinaryStoreException(e); } }
@Test public void testGetStoredMimeType() throws BinaryStoreException { ObjectMetadata objMeta = new ObjectMetadata(); objMeta.setContentType(TEST_MIME); objMeta.addUserMetadata(S3BinaryStore.USER_MIME_TYPE_KEY, String.valueOf(true)); expect(s3Client.getObjectMetadata(BUCKET, TEST_KEY)).andReturn(objMeta); replayAll(); BinaryValue binaryValue = createBinaryValue(TEST_KEY, TEST_CONTENT); String mimeType = s3BinaryStore.getStoredMimeType(binaryValue); assertEquals(TEST_MIME, mimeType); }