List of usage examples for com.amazonaws.services.s3.model ObjectMetadata getHttpExpiresDate
public Date getHttpExpiresDate()
From source file:com.emc.ecs.sync.model.object.S3SyncObject.java
License:Open Source License
protected SyncMetadata toSyncMeta(ObjectMetadata s3meta) { SyncMetadata meta = new SyncMetadata(); meta.setCacheControl(s3meta.getCacheControl()); meta.setContentDisposition(s3meta.getContentDisposition()); meta.setContentEncoding(s3meta.getContentEncoding()); if (s3meta.getContentMD5() != null) meta.setChecksum(new Checksum("MD5", s3meta.getContentMD5())); meta.setContentType(s3meta.getContentType()); meta.setHttpExpires(s3meta.getHttpExpiresDate()); meta.setExpirationDate(s3meta.getExpirationTime()); meta.setModificationTime(s3meta.getLastModified()); meta.setContentLength(s3meta.getContentLength()); meta.setUserMetadata(toMetaMap(s3meta.getUserMetadata())); return meta;/*from w w w . ja v a 2 s. co m*/ }
From source file:com.sangupta.urn.service.impl.AmazonS3UrnStorageServiceImpl.java
License:Apache License
@Override protected UrnObject get(String objectKey) { S3Object object = this.client.getObject(this.bucketName, objectKey); if (object == null) { return null; }/*from w w w .jav a 2 s.c o m*/ try { InputStream stream = object.getObjectContent(); byte[] bytes = IOUtils.toByteArray(stream); UrnObject urnObject = new UrnObject(objectKey, bytes); // TODO: read and populate metadata ObjectMetadata metadata = object.getObjectMetadata(); if (metadata != null) { if (metadata.getHttpExpiresDate() != null) { urnObject.expiry = metadata.getHttpExpiresDate().getTime(); } urnObject.mime = metadata.getContentType(); urnObject.stored = metadata.getLastModified().getTime(); // TODO:parse the value to extract the filename if available urnObject.name = metadata.getContentDisposition(); } // return the object return urnObject; } catch (IOException e) { // happens when we cannot read data from S3 LOGGER.debug("Exception reading data from S3 for object key: " + objectKey, e); return null; } finally { if (object != null) { try { object.close(); } catch (IOException e) { LOGGER.warn("Unable to close S3 object during/after reading the object"); } } } }
From source file:org.xmlsh.aws.util.AWSS3Command.java
License:BSD License
protected void writeMeta(ObjectMetadata m) throws InvalidArgumentException, XMLStreamException, SaxonApiException { mLogger.entry(m);//from w w w . ja v a2s. c o m startElement(sMetaDataElem); attribute("cache-control", m.getCacheControl()); attribute("content-disposition", m.getContentDisposition()); attribute("content-encoding", m.getContentEncoding()); attribute("md5", m.getContentMD5()); attribute("etag", m.getETag()); attribute("version-id", m.getVersionId()); attribute("content-length", String.valueOf(m.getContentLength())); attribute("last-modified", Util.formatXSDateTime(m.getLastModified())); attribute("expiration-time", Util.formatXSDateTime(m.getExpirationTime())); attribute("expiration-time-rule-id", m.getExpirationTimeRuleId()); attribute("httpExpiresDate", Util.formatXSDateTime(m.getHttpExpiresDate())); attribute("ongoingRestore", m.getOngoingRestore()); attribute("restore-expiration-time", Util.formatXSDateTime(m.getRestoreExpirationTime())); attribute("instance-length", m.getInstanceLength()); attribute("sse-algorithm", m.getSSEAlgorithm()); attribute("sse-aws-kms-key-id", m.getSSEAwsKmsKeyId()); attribute("sse-customer-algorithm", m.getSSECustomerAlgorithm()); attribute("sse-customer-key-md5", m.getSSECustomerKeyMd5()); attribute("storage-class", m.getStorageClass()); startElement("user-metadata"); for (Entry<String, String> user : m.getUserMetadata().entrySet()) { startElement(sUserMetaDataElem); attribute("name", user.getKey()); attribute("value", user.getValue()); endElement(); } endElement(); endElement(); mLogger.exit(); }