Refine search
@Override public Multimap<String, String> toHeaders(ContentMetadata md) { Builder<String, String> builder = ImmutableMultimap.builder(); if (md.getContentType() != null) builder.put(CONTENT_TYPE, md.getContentType()); if (md.getContentDisposition() != null) builder.put(CONTENT_DISPOSITION, md.getContentDisposition()); if (md.getContentEncoding() != null) builder.put(CONTENT_ENCODING, md.getContentEncoding()); if (md.getContentLanguage() != null) builder.put(CONTENT_LANGUAGE, md.getContentLanguage()); if (md.getContentLength() != null) builder.put(CONTENT_LENGTH, md.getContentLength() + ""); if (md.getContentMD5() != null) builder.put(CONTENT_MD5, base64().encode(md.getContentMD5())); if (md.getExpires() != null) builder.put(EXPIRES, getExpiresDateCodec().toString(md.getExpires())); return builder.build(); }
BlobMetadata metadata) { ContentMetadata contentMetadata = metadata.getContentMetadata(); addResponseHeaderWithOverride(request, response, HttpHeaders.CACHE_CONTROL, "response-cache-control", contentMetadata.getCacheControl()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_ENCODING, "response-content-encoding", contentMetadata.getContentEncoding()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_LANGUAGE, "response-content-language", contentMetadata.getContentLanguage()); addResponseHeaderWithOverride(request, response, HttpHeaders.CONTENT_DISPOSITION, "response-content-disposition", contentMetadata.getContentDisposition()); response.addHeader(HttpHeaders.CONTENT_LENGTH, contentMetadata.getContentLength().toString()); String overrideContentType = request.getParameter( "response-content-type"); response.setContentType(overrideContentType != null ? overrideContentType : contentMetadata.getContentType()); String eTag = metadata.getETag(); if (eTag != null) { response.addHeader(HttpHeaders.ETAG, maybeQuoteETag(eTag)); response.addHeader(HttpHeaders.EXPIRES, overrideExpires); } else { Date expires = contentMetadata.getExpires(); if (expires != null) {
public SystemMetadata apply(BlobMetadata base) { return new SystemMetadata(base.getContentMetadata().getContentMD5(), null, base.getLastModified(), null, null, null, 1, null, base.getName(), null, (base.getContentMetadata().getContentLength() != null) ? base .getContentMetadata().getContentLength() : 0, FileType.REGULAR, "root"); }
private ImmutableMap<String, String> getContentMetadataForManifest(ContentMetadata contentMetadata) { Builder<String, String> mapBuilder = ImmutableMap.builder(); if (contentMetadata.getContentType() != null) { mapBuilder.put("content-type", contentMetadata.getContentType()); } /** * Do not set content-length. Set automatically to manifest json string length by BindManifestToJsonPayload */ if (contentMetadata.getContentDisposition() != null) { mapBuilder.put("content-disposition", contentMetadata.getContentDisposition()); } if (contentMetadata.getContentEncoding() != null) { mapBuilder.put("content-encoding", contentMetadata.getContentEncoding()); } if (contentMetadata.getContentLanguage() != null) { mapBuilder.put("content-language", contentMetadata.getContentLanguage()); } return mapBuilder.build(); }
public ObjectTemplate apply(BlobMetadata from) { if (from == null) return null; String name = from.getName(); Map<String, String> userMeta = from.getUserMetadata(); ContentMetadata metadata = from.getContentMetadata(); String contentDisposition = metadata.getContentDisposition(); String contentEncoding = metadata.getContentEncoding(); String contentLanguage = metadata.getContentLanguage(); String contentType = metadata.getContentType(); Long contentLength = metadata.getContentLength(); HashCode md5 = metadata.getContentMD5AsHashCode(); ObjectTemplate template = new ObjectTemplate().contentType(contentType).size(contentLength) .contentEncoding(contentEncoding).contentLanguage(contentLanguage) .contentDisposition(contentDisposition).name(name).customMetadata(userMeta); if (md5 != null) { template.md5Hash(base64().encode(md5.asBytes())); } return template; } }
public StorageMetadata apply(BlobMetadata input) { if (input.getContentMetadata().getContentType().equals("application/directory")) { return new StorageMetadataImpl(StorageType.RELATIVE_PATH, input.getProviderId(), input .getName(), input.getLocation(), input.getUri(), input.getETag(), input.getCreationDate(), input.getLastModified(), input.getUserMetadata()); } return input; } }), from.getNextMarker());
.toString(); PayloadBlobBuilder blobBuilder = blobBuilder(mpu.blobName()) .userMetadata(mpu.blobMetadata().getUserMetadata()) .payload(new MultiBlobInputStream(blobs.build())) .contentLength(contentLength) .eTag(mpuETag); String cacheControl = mpu.blobMetadata().getContentMetadata().getCacheControl(); if (cacheControl != null) { blobBuilder.cacheControl(cacheControl); String contentDisposition = mpu.blobMetadata().getContentMetadata().getContentDisposition(); if (contentDisposition != null) { blobBuilder.contentDisposition(contentDisposition); String contentEncoding = mpu.blobMetadata().getContentMetadata().getContentEncoding(); if (contentEncoding != null) { blobBuilder.contentEncoding(contentEncoding); String contentLanguage = mpu.blobMetadata().getContentMetadata().getContentLanguage(); if (contentLanguage != null) { blobBuilder.contentLanguage(contentLanguage); String contentType = mpu.blobMetadata().getContentMetadata().getContentType(); if (contentType != null) { blobBuilder.contentType(contentType); Date expires = mpu.blobMetadata().getContentMetadata().getExpires(); if (expires != null) { blobBuilder.expires(expires);
@Override public MultipartUpload initiateMultipartUpload(String container, BlobMetadata blobMetadata, PutOptions options) { Bucket bucket = getBucket(container); MultipartUploadResponse response = api.getMultipartApi().startLargeFile(bucket.bucketId(), blobMetadata.getName(), blobMetadata.getContentMetadata().getContentType(), blobMetadata.getUserMetadata()); return MultipartUpload.create(container, blobMetadata.getName(), response.fileId(), blobMetadata, options); }
public boolean execute(String containerName, Object value, ListContainerOptions options) { try { byte[] toSearch = objectMD5.apply(value); for (BlobMetadata metadata : getAllBlobMetadata.execute(containerName, options)) { if (Arrays.equals(toSearch, metadata.getContentMetadata().getContentMD5())) return true; } return false; } catch (Exception e) { Throwables.propagateIfPossible(e, BlobRuntimeException.class); throw new BlobRuntimeException(String.format( "Error searching for ETAG of value: [%2$s] in container:%1$s", containerName, value), e); } }
public StorageMetadata execute(String containerName, String directory) { BlobMetadata md = connection.blobMetadata(containerName, directory); if (md != null && md.getContentMetadata().getContentType().equals("application/directory")) return resource2Directory.apply(md); for (String suffix : BlobStoreConstants.DIRECTORY_SUFFIXES) { md = connection.blobMetadata(containerName, directory + suffix); if (md != null) return resource2Directory.apply(md); } return null; } }
protected void validateMetadata(BlobMetadata metadata) throws IOException { assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata() .getContentType(); assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(TEST_STRING.length())); assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff"); checkMD5(metadata); }
private MultipartUpload initiateMultipartUpload(String container, BlobMetadata blobMetadata, long partSize, PutOptions options) { Long contentLength = blobMetadata.getContentMetadata().getContentLength(); String uploadId = String.format(Locale.ENGLISH, "%s/slo/%.6f/%s/%s", blobMetadata.getName(), System.currentTimeMillis() / 1000.0, contentLength == null ? Long.valueOf(0) : contentLength, partSize); return MultipartUpload.create(container, blobMetadata.getName(), uploadId, blobMetadata, options); }
@Override public ContentMetadata apply(@Nullable org.jclouds.io.ContentMetadata input) { if (input == null) { return null; } return ContentMetadata.builder().type(input.getContentType()).disposition(input.getContentDisposition()) .encoding(input.getContentEncoding()).length(input.getContentLength()) .expires(input.getExpires()) .build(); } }
protected <T extends BlobMetadata> T validateMetadata(T md, String container, String name) { assertEquals(md.getName(), name); assertEquals(md.getContainer(), container); assertEquals(md.getSize(), md.getContentMetadata().getContentLength()); return md; }
@Override public MultipartPart uploadMultipartPart(MultipartUpload mpu, int partNumber, Payload payload) { String partName = MULTIPART_PREFIX + mpu.id() + "-" + mpu.blobName() + "-" + partNumber; Blob blob = blobBuilder(partName) .payload(payload) .build(); String partETag = putBlob(mpu.containerName(), blob); BlobMetadata metadata = blobMetadata(mpu.containerName(), partName); // TODO: racy, how to get this from payload? long partSize = metadata.getContentMetadata().getContentLength(); return MultipartPart.create(partNumber, partSize, partETag, metadata.getLastModified()); }
public boolean execute(String containerName, Object value, ListContainerOptions options) { try { byte[] toSearch = objectMD5.apply(value); for (BlobMetadata metadata : getAllBlobMetadata.execute(containerName, options)) { BlobProperties properties = client.getBlobProperties(containerName, metadata.getName()); if (Arrays.equals(toSearch, properties.getContentMetadata().getContentMD5())) return true; } return false; } catch (Exception e) { Throwables.propagateIfPossible(e, BlobRuntimeException.class); throw new BlobRuntimeException(String.format( "Error searching for ETAG of value: [%2$s] in container:%1$s", containerName, value), e); } }
public PayloadIterator(InputStream input, ContentMetadata meta) { this.input = checkNotNull(input, "input"); this.metaData = checkNotNull(meta, "meta"); this.readLen = checkNotNull(this.metaData.getContentLength(), "content-length").intValue(); this.nextPayload = getNextPayload(); }
@Test(groups = "live", dependsOnMethods = "testRewrite") public void testDownload() throws IOException { PayloadEnclosing impl = api().download(BUCKET_NAME, UPLOAD_OBJECT_NAME); ContentMetadata meta = impl.getPayload().getContentMetadata(); assertNotNull(impl); assertNotNull(impl.getPayload()); assertNotNull(meta); assertEquals(meta.getContentType(), "text/plain"); testPayload.getPayload().getContentMetadata().setContentDisposition("attachment"); assertEquals(ByteStreams2.toByteArrayAndClose(impl.getPayload().openStream()), ByteStreams2.toByteArrayAndClose(testPayload.getPayload().openStream())); }
private ImmutableMap<String, String> getContentMetadataForManifest(ContentMetadata contentMetadata) { Builder<String, String> mapBuilder = ImmutableMap.builder(); if (contentMetadata.getContentType() != null) { mapBuilder.put("content-type", contentMetadata.getContentType()); } /** * Do not set content-length. Set automatically to manifest json string length by BindToJsonPayload */ if (contentMetadata.getContentDisposition() != null) { mapBuilder.put("content-disposition", contentMetadata.getContentDisposition()); } if (contentMetadata.getContentEncoding() != null) { mapBuilder.put("content-encoding", contentMetadata.getContentEncoding()); } if (contentMetadata.getContentLanguage() != null) { mapBuilder.put("content-language", contentMetadata.getContentLanguage()); } return mapBuilder.build(); }
public ObjectTemplate apply(BlobMetadata from) { if (from == null) return null; String name = from.getName(); Map<String, String> userMeta = from.getUserMetadata(); ContentMetadata metadata = from.getContentMetadata(); String contentDisposition = metadata.getContentDisposition(); String contentEncoding = metadata.getContentEncoding(); String contentLanguage = metadata.getContentLanguage(); String contentType = metadata.getContentType(); Long contentLength = metadata.getContentLength(); HashCode md5 = metadata.getContentMD5AsHashCode(); ObjectTemplate template = new ObjectTemplate().contentType(contentType).size(contentLength) .contentEncoding(contentEncoding).contentLanguage(contentLanguage) .contentDisposition(contentDisposition).name(name).customMetadata(userMeta) .storageClass(StorageClass.fromTier(from.getTier())); if (md5 != null) { template.md5Hash(base64().encode(md5.asBytes())); } return template; } }