.payload( ephemeral ) .contentMD5(Files.hash( ephemeral, Hashing.md5() )) .contentType("application/json");
.payload( uploadFile ) .contentMD5(Files.hash( uploadFile, Hashing.md5())) .contentType( "application/json" );
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 execute(String containerName, String directory) { blobStore.putBlob( containerName, blobStore.blobBuilder(directory + directorySuffix).type(StorageType.FOLDER) .payload(newByteArrayPayload(new byte[] {})).contentType("application/directory").build()); } }
@Test @Override public void testSignPutBlobWithTime() throws Exception { BlobStore signPutBloblWithTime = requestsSendResponses(init()); Blob blob = signPutBloblWithTime.blobBuilder(OBJECT_NAME).payload(text).contentType("text/plain").build(); HttpRequest compare = _putBlobWithTime(); compare.setPayload(blob.getPayload()); HttpRequest signedRequest = signPutBloblWithTime.getContext().getSigner().signPutBlob(BUCKET_NAME, blob, 86400L /* seconds */); assertEquals(signedRequest, compare); }
public void execute(String containerName, String directory) { blobStore.putBlob( containerName, blobStore.blobBuilder(directory + directorySuffix).type(StorageType.RELATIVE_PATH) .payload(newByteArrayPayload(new byte[] {})).contentType("application/directory").build()); } }
public void execute(String containerName, String directory) { blobStore.putBlob( containerName, blobStore.blobBuilder(directory + directorySuffix).type(StorageType.FOLDER) .payload(newByteArrayPayload(new byte[] {})).contentType("application/directory").build()); } }
public void testSignPutBlobWithGenerate() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { Blob blob = blobFactory.get().name(blobName).payload("foo").calculateMD5().contentType("text/plain").build(); byte[] md5 = new byte[] { -84, -67, 24, -37, 76, -62, -8, 92, -19, -17, 101, 79, -52, -60, -92, -40 }; assertEquals(blob.getPayload().getContentMetadata().getContentMD5(), md5); HttpRequest request = signer.signPutBlob(containerName, blob); assertRequestLineEquals(request, "PUT " + fullUrl + " HTTP/1.1"); assertNonPayloadHeadersEqual( request, "Authorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\nContent-Length: 3\nContent-MD5: rL0Y20zC+Fzt72VPzMSk2A==\nContent-Type: text/plain\n"); assertContentHeadersEqual(request, "text/plain", null, null, null, 3L, md5, null); assertEquals(request.getFilters().size(), 0); }
public void testSignPutBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { Blob blob = blobFactory.get().name(blobName).forSigning().contentLength(2l).contentMD5(new byte[] { 0, 2, 4, 8 }) .contentType("text/plain").build(); assertEquals(blob.getPayload().getContentMetadata().getContentMD5(), new byte[] { 0, 2, 4, 8 }); HttpRequest request = signer.signPutBlob(containerName, blob); assertRequestLineEquals(request, "PUT " + fullUrl + " HTTP/1.1"); assertNonPayloadHeadersEqual( request, "Authorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\nContent-Length: 2\nContent-MD5: AAIECA==\nContent-Type: text/plain\n"); assertContentHeadersEqual(request, "text/plain", null, null, null, 2L, new byte[] { 0, 2, 4, 8 }, null); assertEquals(request.getFilters().size(), 0); }
protected String addBlobToContainer(String sourceContainer, String key, String payload, String contentType) { Blob sourceObject = view.getBlobStore().blobBuilder(key).payload(payload).contentType(contentType).build(); return addBlobToContainer(sourceContainer, sourceObject); }
/** * Writes {@link Payload} to the {@link BlobStore}. */ public static void writeBlob(BlobStore blobStore, String container, String blobName, Payload payload) { if (blobName != null && payload != null) { mkDirs(blobStore, container, blobName); Blob blob = blobStore.blobBuilder(blobName).payload(payload).contentType(MediaType.APPLICATION_OCTET_STREAM).contentDisposition(blobName).build(); blobStore.putBlob(container, blob, multipart()); } }
public void execute(String containerName, String directory) { blobStore.putBlob( containerName, blobStore.blobBuilder(directory + directorySuffix).type(StorageType.RELATIVE_PATH) .payload(newByteArrayPayload(new byte[] {})).contentType("application/directory").build()); } }
public URI apply(Boolean from) { if (path != null) { Blob blob = blobStore.blobBuilder(path + "/").payload("").contentType("application/directory").build(); blobStore.putBlob(container, blob); } return URI.create("http://stub/containers/" + container); }
protected void add5BlobsUnderPathAnd5UnderRootToContainer(String sourceContainer) { for (Entry<String, String> entry : Iterables.concat(fiveStrings.entrySet(), fiveStringsUnderPath.entrySet())) { Blob sourceObject = view.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue()) .contentType("text/xml").build(); addBlobToContainer(sourceContainer, sourceObject); } }
@Test public void testSignPutBlob() throws Exception { BlobStore signPutBlob = requestsSendResponses(init()); Blob blob = signPutBlob.blobBuilder("name").forSigning().contentLength(2l).contentMD5(new byte[] { 0, 2, 4, 8 }) .contentType("text/plain").expires(new Date(1000)).build(); HttpRequest compare = putBlob(); compare.setPayload(blob.getPayload()); assertEquals(signPutBlob.getContext().getSigner().signPutBlob(container, blob), compare); }
private void uploadConstitution(String container, String name, String contentDisposition) throws IOException { view.getBlobStore().putBlob( container, view.getBlobStore().blobBuilder(name).payload(oneHundredOneConstitutions.getInput()).contentType( "text/plain").contentMD5(oneHundredOneConstitutionsMD5).contentLength( oneHundredOneConstitutionsLength).contentDisposition(contentDisposition).build()); }
@Test public void testSignPutBlobWithTime() throws Exception { BlobStore signPutBloblWithTime = requestsSendResponses(init()); Blob blob = signPutBloblWithTime.blobBuilder(name).payload(text).contentType("text/plain").build(); HttpRequest compare = putBlobWithTime(); compare.setPayload(blob.getPayload()); assertEquals(signPutBloblWithTime.getContext().getSigner().signPutBlob(container, blob, 3l /* seconds */), compare); }
private void addContentMetadata(PayloadBlobBuilder blobBuilder) { blobBuilder.contentType("text/csv"); blobBuilder.contentDisposition("attachment; filename=photo.jpg"); blobBuilder.contentEncoding("gzip"); blobBuilder.contentLanguage("en"); }
.payload(payload); if (contentType != null) { builder.contentType(contentType);
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(); } } }