public MutableObjectMetadata apply(BlobMetadata from) { if (from == null) return null; MutableObjectMetadata to = new MutableObjectMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setETag(from.getETag()); to.setKey(from.getName()); to.setLastModified(from.getLastModified()); if (from.getUserMetadata() != null) { for (Entry<String, String> entry : from.getUserMetadata().entrySet()) to.getUserMetadata().put(entry.getKey().toLowerCase(), entry.getValue()); } return to; } }
/** * parses the http response headers to create a new * {@link org.jclouds.aws.s3.domain.internal.MutableObjectMetadata} object. */ public MutableObjectMetadata apply(HttpResponse from) { BlobMetadata base = blobMetadataParser.apply(from); MutableObjectMetadata to = blobToObjectMetadata.apply(base); addETagTo(from, to); if (to.getContentMetadata().getContentMD5() == null && to.getETag() != null) { byte[] md5 = CryptoStreams.hex(to.getETag().replaceAll("\"", "")); // it is possible others will look at the http payload directly from.getPayload().getContentMetadata().setContentMD5(md5); to.getContentMetadata().setContentMD5(md5); } to.setCacheControl(from.getFirstHeaderOrNull(HttpHeaders.CACHE_CONTROL)); return to; }
@Override public void setPayload(Payload data) { super.setPayload(data); metadata.setContentMetadata(data.getContentMetadata()); }
public void bindToRequest(HttpRequest request, Object payload) { S3Object s3Object = (S3Object) payload; checkArgument(s3Object.getPayload().getContentMetadata().getContentLength() != null, "contentLength must be set, streaming not supported"); checkArgument(s3Object.getPayload().getContentMetadata().getContentLength() <= 5l * 1024 * 1024 * 1024, "maximum size for put object is 5GB"); blobBinder.bindToRequest(request, object2Blob.apply(s3Object)); if (s3Object.getMetadata().getCacheControl() != null) { request.getHeaders().put(HttpHeaders.CACHE_CONTROL, s3Object.getMetadata().getCacheControl()); } } }
public String apply(Object from) { return ((S3Object) from).getMetadata().getKey(); }