private static void addContentMetdataFromHttpRequest( BlobBuilder.PayloadBlobBuilder builder, HttpServletRequest request) { ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder(); for (String headerName : Collections.list(request.getHeaderNames())) { if (startsWithIgnoreCase(headerName, USER_METADATA_PREFIX)) { userMetadata.put( headerName.substring(USER_METADATA_PREFIX.length()), Strings.nullToEmpty(request.getHeader(headerName))); } } builder.cacheControl(request.getHeader( HttpHeaders.CACHE_CONTROL)) .contentDisposition(request.getHeader( HttpHeaders.CONTENT_DISPOSITION)) .contentEncoding(request.getHeader( HttpHeaders.CONTENT_ENCODING)) .contentLanguage(request.getHeader( HttpHeaders.CONTENT_LANGUAGE)) .userMetadata(userMetadata.build()); String contentType = request.getContentType(); if (contentType != null) { builder.contentType(contentType); } long expires = request.getDateHeader(HttpHeaders.EXPIRES); if (expires != -1) { builder.expires(new Date(expires)); } }
private static void addContentMetdataFromHttpRequest( BlobBuilder.PayloadBlobBuilder builder, HttpServletRequest request) { ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder(); for (String headerName : Collections.list(request.getHeaderNames())) { if (startsWithIgnoreCase(headerName, USER_METADATA_PREFIX)) { userMetadata.put( headerName.substring(USER_METADATA_PREFIX.length()), Strings.nullToEmpty(request.getHeader(headerName))); } } builder.cacheControl(request.getHeader( HttpHeaders.CACHE_CONTROL)) .contentDisposition(request.getHeader( HttpHeaders.CONTENT_DISPOSITION)) .contentEncoding(request.getHeader( HttpHeaders.CONTENT_ENCODING)) .contentLanguage(request.getHeader( HttpHeaders.CONTENT_LANGUAGE)) .userMetadata(userMetadata.build()); String contentType = request.getContentType(); if (contentType != null) { builder.contentType(contentType); } long expires = request.getDateHeader(HttpHeaders.EXPIRES); if (expires != -1) { builder.expires(new Date(expires)); } }
private static void addContentMetdataFromHttpRequest( BlobBuilder.PayloadBlobBuilder builder, HttpServletRequest request) { ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder(); for (String headerName : Collections.list(request.getHeaderNames())) { if (startsWithIgnoreCase(headerName, USER_METADATA_PREFIX)) { userMetadata.put( headerName.substring(USER_METADATA_PREFIX.length()), Strings.nullToEmpty(request.getHeader(headerName))); } } builder.cacheControl(request.getHeader( HttpHeaders.CACHE_CONTROL)) .contentDisposition(request.getHeader( HttpHeaders.CONTENT_DISPOSITION)) .contentEncoding(request.getHeader( HttpHeaders.CONTENT_ENCODING)) .contentLanguage(request.getHeader( HttpHeaders.CONTENT_LANGUAGE)) .userMetadata(userMetadata.build()); String contentType = request.getContentType(); if (contentType != null) { builder.contentType(contentType); } long expires = request.getDateHeader(HttpHeaders.EXPIRES); if (expires != -1) { builder.expires(new Date(expires)); } }
builder.contentLanguage(contentLanguage); .contentDisposition(metadata.getContentDisposition()) .contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
builder.contentLanguage(contentLanguage); .contentDisposition(metadata.getContentDisposition()) .contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
blobBuilder.contentLanguage(contentLanguage);
.contentDisposition(metadata.getContentDisposition()) .contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
.contentDisposition(metadata.getContentDisposition()) .contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
payloadBuilder.contentLanguage(value); break;
.contentDisposition("attachment; filename=original.jpg") .contentEncoding("compress") .contentLanguage("fr") .contentType("audio/ogg"); Blob blob = blobBuilder.build();
blobBuilder.contentLanguage(contentLanguage);
blobBuilder.contentLanguage(contentLanguage);
.contentDisposition(metadata.getContentDisposition()) .contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
blobBuilder.contentLanguage(contentLanguage);
.contentDisposition(metadata.getContentDisposition()) .contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
private String emulateCopyBlob(BlobStore blobStore, Response resp, BlobMetadata meta, String destContainer, String destObject, CopyOptions options) { Response.StatusType statusInfo = resp.getStatusInfo(); if (statusInfo.equals(Response.Status.OK)) { ContentMetadata contentMetadata = meta.getContentMetadata(); Map<String, String> newMetadata = new HashMap<>(); newMetadata.putAll(meta.getUserMetadata()); newMetadata.putAll(options.userMetadata()); RESERVED_METADATA.forEach(s -> newMetadata.remove(s)); Blob blob = blobStore.blobBuilder(destObject) .userMetadata(newMetadata) .payload(new InputStreamPayload((InputStream) resp.getEntity())) .contentLength(resp.getLength()) .contentDisposition(contentMetadata.getContentDisposition()) .contentEncoding(contentMetadata.getContentEncoding()) .contentType(contentMetadata.getContentType()) .contentLanguage(contentMetadata.getContentLanguage()) .build(); return blobStore.putBlob(destContainer, blob); } else { throw new ClientErrorException(statusInfo.getReasonPhrase(), statusInfo.getStatusCode()); } }
@Test(groups = "live") public void testPutBlobWithMd5() throws IOException, InterruptedException { String containerName = getContainerName(); String blobName = "md5test"; try { long contentLength = 32 * 1024L; ByteSource byteSource = TestUtils.randomByteSource().slice(0, contentLength); ByteSourcePayload payload = Payloads.newByteSourcePayload(byteSource); PayloadEnclosingImpl payloadImpl = new PayloadEnclosingImpl(payload); BlobStore blobStore = view.getBlobStore(); // This would trigger server side validation of md5 HashCode hcMd5 = byteSource.hash(Hashing.md5()); Blob blob = blobStore.blobBuilder(blobName).payload(payloadImpl.getPayload()).contentType("image/jpeg") .contentLength(contentLength).contentLanguage("en").contentDisposition("attachment") .contentMD5(hcMd5).userMetadata(ImmutableMap.of("Adrian", "powderpuff")).build(); blobStore.putBlob(containerName, blob); checkMD5(containerName, blobName, hcMd5.asBytes()); } finally { returnContainer(containerName); } } }
@Override protected void addContentMetadata(PayloadBlobBuilder blobBuilder) { blobBuilder.contentType("text/csv"); blobBuilder.contentDisposition("attachment; filename=photo.jpg"); // TODO: causes failures with subsequent GET operations: // HTTP/1.1 failed with response: HTTP/1.1 503 Service Unavailable; content: [Service Unavailable] //blobBuilder.contentEncoding("gzip"); blobBuilder.contentLanguage("en"); }
protected void addContentMetadata(PayloadBlobBuilder blobBuilder) { blobBuilder.cacheControl("max-age=3600"); blobBuilder.contentType("text/csv"); blobBuilder.contentDisposition("attachment; filename=photo.jpg"); blobBuilder.contentEncoding("gzip"); blobBuilder.contentLanguage("en"); }
private void addContentMetadata(PayloadBlobBuilder blobBuilder) { blobBuilder.contentType("text/csv"); blobBuilder.contentDisposition("attachment; filename=photo.jpg"); blobBuilder.contentEncoding("gzip"); blobBuilder.contentLanguage("en"); }