@Test public void testPassWithMinimumDetailsAndPayload5GB() { ObjectMetadata md = ObjectMetadataBuilder.create().key("foo").build(); HttpRequest request = HttpRequest.builder().method("POST").endpoint("http: BindObjectMetadataToRequest binder = injector.getInstance(BindObjectMetadataToRequest.class); assertEquals(binder.bindToRequest(request, md), HttpRequest.builder().method("POST") .endpoint("http: }
@SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof ObjectMetadata, "this binder is only valid for ObjectMetadata!"); checkNotNull(request, "request"); ObjectMetadata md = ObjectMetadata.class.cast(input); checkArgument(md.getKey() != null, "objectMetadata.getKey() must be set!"); request = metadataPrefixer.bindToRequest(request, md.getUserMetadata()); Builder<String, String> headers = ImmutableMultimap.builder(); if (md.getContentMetadata().getCacheControl() != null) { headers.put(HttpHeaders.CACHE_CONTROL, md.getContentMetadata().getCacheControl()); } if (md.getContentMetadata().getContentDisposition() != null) { headers.put("Content-Disposition", md.getContentMetadata().getContentDisposition()); } if (md.getContentMetadata().getContentEncoding() != null) { headers.put("Content-Encoding", md.getContentMetadata().getContentEncoding()); } String contentLanguage = md.getContentMetadata().getContentLanguage(); if (contentLanguage != null) { headers.put(HttpHeaders.CONTENT_LANGUAGE, contentLanguage); } if (md.getContentMetadata().getContentType() != null) { headers.put(HttpHeaders.CONTENT_TYPE, md.getContentMetadata().getContentType()); } else { headers.put(HttpHeaders.CONTENT_TYPE, "binary/octet-stream"); } if (md.getContentMetadata().getContentMD5() != null) { headers.put("Content-MD5", base64().encode(md.getContentMetadata().getContentMD5())); } ObjectMetadata.StorageClass storageClass = md.getStorageClass(); if (storageClass != ObjectMetadata.StorageClass.STANDARD) { headers.put("x-amz-storage-class", storageClass.toString()); } return (R) request.toBuilder().replaceHeaders(headers.build()).build(); }
BindObjectMetadataToRequest implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof ObjectMetadata, "this binder is only valid for ObjectMetadata!"); checkNotNull(request, "request"); ObjectMetadata md = ObjectMetadata.class.cast(input); checkArgument(md.getKey() != null, "objectMetadata.getKey() must be set!"); request = metadataPrefixer.bindToRequest(request, md.getUserMetadata()); Builder<String, String> headers = ImmutableMultimap.builder(); if (md.getContentMetadata().getCacheControl() != null) { headers.put(HttpHeaders.CACHE_CONTROL, md.getContentMetadata().getCacheControl()); } if (md.getContentMetadata().getContentDisposition() != null) { headers.put("Content-Disposition", md.getContentMetadata().getContentDisposition()); } if (md.getContentMetadata().getContentEncoding() != null) { headers.put("Content-Encoding", md.getContentMetadata().getContentEncoding()); } String contentLanguage = md.getContentMetadata().getContentLanguage(); if (contentLanguage != null) { headers.put(HttpHeaders.CONTENT_LANGUAGE, contentLanguage); } if (md.getContentMetadata().getContentType() != null) { headers.put(HttpHeaders.CONTENT_TYPE, md.getContentMetadata().getContentType()); } else { headers.put(HttpHeaders.CONTENT_TYPE, "binary/octet-stream"); } if (md.getContentMetadata().getContentMD5() != null) { headers.put("Content-MD5", base64().encode(md.getContentMetadata().getContentMD5())); } ObjectMetadata.StorageClass storageClass = md.getStorageClass(); if (storageClass != ObjectMetadata.StorageClass.STANDARD) { headers.put("x-amz-storage-class", storageClass.toString()); } return (R) request.toBuilder().replaceHeaders(headers.build()).build(); } }
BindObjectMetadataToRequest implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof ObjectMetadata, "this binder is only valid for ObjectMetadata!"); checkNotNull(request, "request"); ObjectMetadata md = ObjectMetadata.class.cast(input); checkArgument(md.getKey() != null, "objectMetadata.getKey() must be set!"); request = metadataPrefixer.bindToRequest(request, md.getUserMetadata()); Builder<String, String> headers = ImmutableMultimap.builder(); if (md.getContentMetadata().getCacheControl() != null) { headers.put(HttpHeaders.CACHE_CONTROL, md.getContentMetadata().getCacheControl()); } if (md.getContentMetadata().getContentDisposition() != null) { headers.put("Content-Disposition", md.getContentMetadata().getContentDisposition()); } if (md.getContentMetadata().getContentEncoding() != null) { headers.put("Content-Encoding", md.getContentMetadata().getContentEncoding()); } String contentLanguage = md.getContentMetadata().getContentLanguage(); if (contentLanguage != null) { headers.put(HttpHeaders.CONTENT_LANGUAGE, contentLanguage); } if (md.getContentMetadata().getContentType() != null) { headers.put(HttpHeaders.CONTENT_TYPE, md.getContentMetadata().getContentType()); } else { headers.put(HttpHeaders.CONTENT_TYPE, "binary/octet-stream"); } if (md.getContentMetadata().getContentMD5() != null) { headers.put("Content-MD5", base64().encode(md.getContentMetadata().getContentMD5())); } ObjectMetadata.StorageClass storageClass = md.getStorageClass(); if (storageClass != ObjectMetadata.StorageClass.STANDARD) { headers.put("x-amz-storage-class", storageClass.toString()); } return (R) request.toBuilder().replaceHeaders(headers.build()).build(); } @Inject  BindObjectMetadataToRequest(BindMapToHeadersWithPrefix metadataPrefixer); }
BindObjectMetadataToRequest implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof ObjectMetadata, "this binder is only valid for ObjectMetadata!"); checkNotNull(request, "request"); ObjectMetadata md = ObjectMetadata.class.cast(input); checkArgument(md.getKey() != null, "objectMetadata.getKey() must be set!"); request = metadataPrefixer.bindToRequest(request, md.getUserMetadata()); Builder<String, String> headers = ImmutableMultimap.builder(); if (md.getContentMetadata().getCacheControl() != null) { headers.put(HttpHeaders.CACHE_CONTROL, md.getContentMetadata().getCacheControl()); } if (md.getContentMetadata().getContentDisposition() != null) { headers.put("Content-Disposition", md.getContentMetadata().getContentDisposition()); } if (md.getContentMetadata().getContentEncoding() != null) { headers.put("Content-Encoding", md.getContentMetadata().getContentEncoding()); } String contentLanguage = md.getContentMetadata().getContentLanguage(); if (contentLanguage != null) { headers.put(HttpHeaders.CONTENT_LANGUAGE, contentLanguage); } if (md.getContentMetadata().getContentType() != null) { headers.put(HttpHeaders.CONTENT_TYPE, md.getContentMetadata().getContentType()); } else { headers.put(HttpHeaders.CONTENT_TYPE, "binary/octet-stream"); } if (md.getContentMetadata().getContentMD5() != null) { headers.put("Content-MD5", base64().encode(md.getContentMetadata().getContentMD5())); } ObjectMetadata.StorageClass storageClass = md.getStorageClass(); if (storageClass != ObjectMetadata.StorageClass.STANDARD) { headers.put("x-amz-storage-class", storageClass.toString()); } return (R) request.toBuilder().replaceHeaders(headers.build()).build(); } @Inject  BindObjectMetadataToRequest(BindMapToHeadersWithPrefix metadataPrefixer); @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Object input); }
BindObjectMetadataToRequest implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof ObjectMetadata, "this binder is only valid for ObjectMetadata!"); checkNotNull(request, "request"); ObjectMetadata md = ObjectMetadata.class.cast(input); checkArgument(md.getKey() != null, "objectMetadata.getKey() must be set!"); request = metadataPrefixer.bindToRequest(request, md.getUserMetadata()); Builder<String, String> headers = ImmutableMultimap.builder(); if (md.getContentMetadata().getCacheControl() != null) { headers.put(HttpHeaders.CACHE_CONTROL, md.getContentMetadata().getCacheControl()); } if (md.getContentMetadata().getContentDisposition() != null) { headers.put("Content-Disposition", md.getContentMetadata().getContentDisposition()); } if (md.getContentMetadata().getContentEncoding() != null) { headers.put("Content-Encoding", md.getContentMetadata().getContentEncoding()); } String contentLanguage = md.getContentMetadata().getContentLanguage(); if (contentLanguage != null) { headers.put(HttpHeaders.CONTENT_LANGUAGE, contentLanguage); } if (md.getContentMetadata().getContentType() != null) { headers.put(HttpHeaders.CONTENT_TYPE, md.getContentMetadata().getContentType()); } else { headers.put(HttpHeaders.CONTENT_TYPE, "binary/octet-stream"); } if (md.getContentMetadata().getContentMD5() != null) { headers.put("Content-MD5", base64().encode(md.getContentMetadata().getContentMD5())); } ObjectMetadata.StorageClass storageClass = md.getStorageClass(); if (storageClass != ObjectMetadata.StorageClass.STANDARD) { headers.put("x-amz-storage-class", storageClass.toString()); } return (R) request.toBuilder().replaceHeaders(headers.build()).build(); } @Inject  BindObjectMetadataToRequest(BindMapToHeadersWithPrefix metadataPrefixer); @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Object input);  }