/** * Returns an object representing the details of an item in S3 without the object's data, and * without applying any preconditions. * * @deprecated 0.8.0 * * <p> * This method can be performed by anonymous services. Anonymous services * can get a publicly-readable object's details. * * @param bucket * the bucket containing the object. * This must be a valid S3Bucket object that is non-null and contains a name. * @param objectKey * the key identifying the object. * @return * the object with the given key in S3, including only general details and metadata (not the data * input stream) * @throws S3ServiceException */ @Deprecated public S3Object getObjectDetails(S3Bucket bucket, String objectKey) throws S3ServiceException { try { assertValidBucket(bucket, "getObjectDetails"); return getObjectDetails(bucket, objectKey, null, null, null, null); } catch (ServiceException se) { throw new S3ServiceException(se); } }
/** * Returns an object representing the details of an item in S3 without the object's data, and * without applying any preconditions. * * @deprecated 0.8.0 * * <p> * This method can be performed by anonymous services. Anonymous services * can get a publicly-readable object's details. * * @param bucket * the bucket containing the object. * This must be a valid S3Bucket object that is non-null and contains a name. * @param objectKey * the key identifying the object. * @return * the object with the given key in S3, including only general details and metadata (not the data * input stream) * @throws S3ServiceException */ @Deprecated public S3Object getObjectDetails(S3Bucket bucket, String objectKey) throws S3ServiceException { try { assertValidBucket(bucket, "getObjectDetails"); return getObjectDetails(bucket, objectKey, null, null, null, null); } catch (ServiceException se) { throw new S3ServiceException(se); } }
public FileMetadata retrieveMetadata(String key) throws IOException { try { S3Object object = s3Service.getObjectDetails(bucket, key); return new FileMetadata(key, object.getContentLength(), object.getLastModifiedDate().getTime()); } catch (S3ServiceException e) { // Following is brittle. Is there a better way? if (e.getMessage().contains("ResponseCode=404")) { return null; } if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } }
public FileMetadata retrieveMetadata(String key) throws IOException { try { S3Object object = s3Service.getObjectDetails(bucket, key); return new FileMetadata(key, object.getContentLength(), object.getLastModifiedDate().getTime()); } catch (S3ServiceException e) { // Following is brittle. Is there a better way? if (e.getMessage().contains("ResponseCode=404")) { return null; } if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } }
public void run() { try { if (headOnly) { if (signedGetOrHeadUrl == null) { result = s3Service.getObjectDetails(bucket, objectKey); } else { SignedUrlHandler handler = s3Service; result = handler.getObjectDetailsWithSignedUrl(signedGetOrHeadUrl); } } else { if (signedGetOrHeadUrl == null) { result = s3Service.getObject(bucket, objectKey); } else { SignedUrlHandler handler = s3Service; result = handler.getObjectWithSignedUrl(signedGetOrHeadUrl); } } } catch (ServiceException se) { result = new S3ServiceException(se); } }
public void run() { try { if (headOnly) { if (signedGetOrHeadUrl == null) { result = s3Service.getObjectDetails(bucket, objectKey); } else { SignedUrlHandler handler = s3Service; result = handler.getObjectDetailsWithSignedUrl(signedGetOrHeadUrl); } } else { if (signedGetOrHeadUrl == null) { result = s3Service.getObject(bucket, objectKey); } else { SignedUrlHandler handler = s3Service; result = handler.getObjectWithSignedUrl(signedGetOrHeadUrl); } } } catch (ServiceException se) { result = new S3ServiceException(se); } }
@Override public FileMetadata retrieveMetadata(String key) throws IOException { StorageObject object = null; try { LOG.debug("Getting metadata for key: {} from bucket: {}", key, bucket.getName()); object = s3Service.getObjectDetails(bucket.getName(), key); return new FileMetadata(key, object.getContentLength(), object.getLastModifiedDate().getTime()); } catch (ServiceException e) { try { // process handleException(e, key); return null; } catch (FileNotFoundException fnfe) { // and downgrade missing files return null; } } finally { if (object != null) { object.closeDataInputStream(); } } }
@Override public void copy(String srcKey, String dstKey) throws IOException { try { if(LOG.isDebugEnabled()) { LOG.debug("Copying srcKey: " + srcKey + "to dstKey: " + dstKey + "in bucket: " + bucket.getName()); } if (multipartEnabled) { S3Object object = s3Service.getObjectDetails(bucket, srcKey, null, null, null, null); if (multipartCopyBlockSize > 0 && object.getContentLength() > multipartCopyBlockSize) { copyLargeFile(object, dstKey); return; } } S3Object dstObject = new S3Object(dstKey); dstObject.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); s3Service.copyObject(bucket.getName(), srcKey, bucket.getName(), dstObject, false); } catch (ServiceException e) { handleException(e, srcKey); } }
private void fetchAttributes() throws AuthException { try { setAttributes(service.getObjectDetails(bucketName, getObjectKey(), null, null, null, null)); // Object does not exist on the server setExists(true); } catch(S3ServiceException e) { // Object does not exist on the server, or could not be retrieved setExists(false); setDirectory(false); setSize(0); setDate(0); setPermissions(FilePermissions.EMPTY_FILE_PERMISSIONS); setOwner(null); handleAuthException(e, fileURL); } }