List of usage examples for com.amazonaws.services.s3.model ObjectMetadata getExpirationTimeRuleId
public String getExpirationTimeRuleId()
From source file:com.emc.vipr.services.s3.ViPRS3Client.java
License:Open Source License
public UpdateObjectResult updateObject(UpdateObjectRequest request) throws AmazonClientException { ObjectMetadata returnedMetadata = doPut(request); UpdateObjectResult result = new UpdateObjectResult(); result.setETag(returnedMetadata.getETag()); result.setVersionId(returnedMetadata.getVersionId()); result.setServerSideEncryption(returnedMetadata.getServerSideEncryption()); result.setExpirationTime(returnedMetadata.getExpirationTime()); result.setExpirationTimeRuleId(returnedMetadata.getExpirationTimeRuleId()); return result; }
From source file:com.emc.vipr.services.s3.ViPRS3Client.java
License:Open Source License
public AppendObjectResult appendObject(AppendObjectRequest request) throws AmazonClientException { ObjectMetadata returnedMetadata = doPut(request); AppendObjectResult result = new AppendObjectResult(); result.setETag(returnedMetadata.getETag()); result.setVersionId(returnedMetadata.getVersionId()); result.setServerSideEncryption(returnedMetadata.getServerSideEncryption()); result.setExpirationTime(returnedMetadata.getExpirationTime()); result.setExpirationTimeRuleId(returnedMetadata.getExpirationTimeRuleId()); result.setAppendOffset(//from w ww . j av a2 s . c om Long.parseLong("" + returnedMetadata.getRawMetadata().get(ViPRConstants.APPEND_OFFSET_HEADER))); return result; }
From source file:org.apache.nifi.processors.aws.s3.FetchS3Object.java
License:Apache License
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) { FlowFile flowFile = session.get();/*from w ww . j a v a 2 s. c om*/ if (flowFile == null) { return; } final long startNanos = System.nanoTime(); final String bucket = context.getProperty(BUCKET).evaluateAttributeExpressions(flowFile).getValue(); final String key = context.getProperty(KEY).evaluateAttributeExpressions(flowFile).getValue(); final String versionId = context.getProperty(VERSION_ID).evaluateAttributeExpressions(flowFile).getValue(); final AmazonS3 client = getClient(); final GetObjectRequest request; if (versionId == null) { request = new GetObjectRequest(bucket, key); } else { request = new GetObjectRequest(bucket, key, versionId); } final Map<String, String> attributes = new HashMap<>(); try (final S3Object s3Object = client.getObject(request)) { flowFile = session.importFrom(s3Object.getObjectContent(), flowFile); attributes.put("s3.bucket", s3Object.getBucketName()); final ObjectMetadata metadata = s3Object.getObjectMetadata(); if (metadata.getContentDisposition() != null) { final String fullyQualified = metadata.getContentDisposition(); final int lastSlash = fullyQualified.lastIndexOf("/"); if (lastSlash > -1 && lastSlash < fullyQualified.length() - 1) { attributes.put(CoreAttributes.PATH.key(), fullyQualified.substring(0, lastSlash)); attributes.put(CoreAttributes.ABSOLUTE_PATH.key(), fullyQualified); attributes.put(CoreAttributes.FILENAME.key(), fullyQualified.substring(lastSlash + 1)); } else { attributes.put(CoreAttributes.FILENAME.key(), metadata.getContentDisposition()); } } if (metadata.getContentMD5() != null) { attributes.put("hash.value", metadata.getContentMD5()); attributes.put("hash.algorithm", "MD5"); } if (metadata.getContentType() != null) { attributes.put(CoreAttributes.MIME_TYPE.key(), metadata.getContentType()); } if (metadata.getETag() != null) { attributes.put("s3.etag", metadata.getETag()); } if (metadata.getExpirationTime() != null) { attributes.put("s3.expirationTime", String.valueOf(metadata.getExpirationTime().getTime())); } if (metadata.getExpirationTimeRuleId() != null) { attributes.put("s3.expirationTimeRuleId", metadata.getExpirationTimeRuleId()); } if (metadata.getUserMetadata() != null) { attributes.putAll(metadata.getUserMetadata()); } if (metadata.getSSEAlgorithm() != null) { attributes.put("s3.sseAlgorithm", metadata.getSSEAlgorithm()); } if (metadata.getVersionId() != null) { attributes.put("s3.version", metadata.getVersionId()); } } catch (final IOException | AmazonClientException ioe) { getLogger().error("Failed to retrieve S3 Object for {}; routing to failure", new Object[] { flowFile, ioe }); flowFile = session.penalize(flowFile); session.transfer(flowFile, REL_FAILURE); return; } if (!attributes.isEmpty()) { flowFile = session.putAllAttributes(flowFile, attributes); } session.transfer(flowFile, REL_SUCCESS); final long transferMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos); getLogger().info("Successfully retrieved S3 Object for {} in {} millis; routing to success", new Object[] { flowFile, transferMillis }); session.getProvenanceReporter().fetch(flowFile, "http://" + bucket + ".amazonaws.com/" + key, transferMillis); }
From source file:org.xmlsh.aws.util.AWSS3Command.java
License:BSD License
protected void writeMeta(ObjectMetadata m) throws InvalidArgumentException, XMLStreamException, SaxonApiException { mLogger.entry(m);// w w w .java 2 s .co 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(); }