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)); } }
public void publish(String remoteName, byte[] payload) throws IOException { Timer.Context ctx = uploadTimer.time(); try { Blob blob = blobStore.blobBuilder(remoteName).payload(payload) .contentType("application/json") .contentEncoding(remoteName.endsWith(".gz") ? "gzip" : "identity") .calculateMD5().build(); String containerName = CONTAINER_DATE_FORMAT.format(new Date()); if (!lastContainerCreated.matches(containerName)) { createContainer(); } blobStore.putBlob(containerName, blob); } finally { ctx.stop(); } } }
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)); } }
.cacheControl(cacheControl) .contentDisposition(contentDisposition) .contentEncoding(contentEncoding) .contentLanguage(contentLanguage) .contentLength(byteSource.size())
builder.contentEncoding(contentEncoding); builder.cacheControl(metadata.getCacheControl()) .contentDisposition(metadata.getContentDisposition()) .contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
blobBuilder.contentEncoding(contentEncoding);
builder.contentEncoding(contentEncoding); builder.cacheControl(metadata.getCacheControl()) .contentDisposition(metadata.getContentDisposition()) .contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
.contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
.contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
payloadBuilder.contentEncoding(value); break;
.contentLength(payload.size()) .contentDisposition("attachment; filename=original.jpg") .contentEncoding("compress") .contentLanguage("fr") .contentType("audio/ogg");
blobBuilder.contentEncoding(contentEncoding);
blobBuilder.contentEncoding(contentEncoding);
blobBuilder.contentEncoding(contentEncoding);
.contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
.contentEncoding(metadata.getContentEncoding()) .contentLanguage(metadata.getContentLanguage()) .contentType(metadata.getContentType());
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 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()); } }
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"); }