@Override public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) { ImmutableList.Builder<Segment> builder = ImmutableList.builder(); for (MultipartPart part : parts) { String path = mpu.containerName() + "/" + getMPUPartName(mpu, part.partNumber()); builder.add(Segment.builder().path(path).etag(part.partETag()).sizeBytes(part.partSize()).build()); } return api.getStaticLargeObjectApi(regionId, mpu.containerName()).replaceManifest(mpu.blobName(), builder.build(), mpu.blobMetadata().getUserMetadata(), getContentMetadataForManifest(mpu.blobMetadata().getContentMetadata())); }
@Override public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) { ImmutableList.Builder<Segment> builder = ImmutableList.builder(); for (MultipartPart part : parts) { String path = mpu.containerName() + "/" + getMPUPartName(mpu, part.partNumber()); builder.add(Segment.builder().path(path).etag(part.partETag()).sizeBytes(part.partSize()).build()); } return api.getStaticLargeObjectApi(regionId, mpu.containerName()).replaceManifest(mpu.blobName(), builder.build(), mpu.blobMetadata().getUserMetadata(), getContentMetadataForManifest(mpu.blobMetadata().getContentMetadata())); }
@Override public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) { ImmutableList.Builder<Segment> builder = ImmutableList.builder(); for (MultipartPart part : parts) { String path = mpu.containerName() + "/" + getMPUPartName(mpu, part.partNumber()); builder.add(Segment.builder().path(path).etag(part.partETag()).sizeBytes(part.partSize()).build()); } return api.getStaticLargeObjectApi(regionId, mpu.containerName()).replaceManifest(mpu.blobName(), builder.build(), mpu.blobMetadata().getUserMetadata(), getContentMetadataForManifest(mpu.blobMetadata().getContentMetadata())); }
@Override public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) { AzureBlob azureBlob = sync.newBlob(); // fake values to satisfy BindAzureBlobMetadataToMultipartRequest azureBlob.setPayload(new byte[0]); azureBlob.getProperties().setContainer(mpu.containerName()); azureBlob.getProperties().setName(mpu.blobName()); azureBlob.getProperties().setContentMetadata((MutableContentMetadata) mpu.blobMetadata().getContentMetadata()); azureBlob.getProperties().setMetadata(mpu.blobMetadata().getUserMetadata()); ImmutableList.Builder<String> blocks = ImmutableList.builder(); for (MultipartPart part : parts) { String blockId = BaseEncoding.base64().encode(Ints.toByteArray(part.partNumber())); blocks.add(blockId); } return sync.putBlockList(mpu.containerName(), azureBlob, blocks.build()); }
@Override public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) { AzureBlob azureBlob = sync.newBlob(); // fake values to satisfy BindAzureBlobMetadataToMultipartRequest azureBlob.setPayload(new byte[0]); azureBlob.getProperties().setContainer(mpu.containerName()); azureBlob.getProperties().setName(mpu.blobName()); azureBlob.getProperties().setContentMetadata((MutableContentMetadata) mpu.blobMetadata().getContentMetadata()); azureBlob.getProperties().setMetadata(mpu.blobMetadata().getUserMetadata()); ImmutableList.Builder<String> blocks = ImmutableList.builder(); for (MultipartPart part : parts) { String blockId = BaseEncoding.base64().encode(Ints.toByteArray(part.partNumber())); blocks.add(blockId); } return sync.putBlockList(mpu.containerName(), azureBlob, blocks.build()); }
.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);
.userMetadata(mpu.blobMetadata().getUserMetadata()) .payload(new SequenceInputStream(Iterators.asEnumeration(streams.build().iterator()))) .contentLength(contentLength); 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); Tier tier = mpu.blobMetadata().getTier(); if (tier != null) {
.userMetadata(mpu.blobMetadata().getUserMetadata()) .payload(new SequenceInputStream(Iterators.asEnumeration(streams.build().iterator()))) .contentLength(contentLength); 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);
.userMetadata(mpu.blobMetadata().getUserMetadata()) .payload(new SequenceInputStream(Iterators.asEnumeration(streams.build().iterator()))) .contentLength(contentLength); 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);
ObjectTemplate destination = blobMetadataToObjectTemplate.apply(mpu.blobMetadata()); final ImmutableList<GoogleCloudStorageObject> objects = objectsBuilder.build(); if (!objects.isEmpty()) {
ObjectTemplate destination = blobMetadataToObjectTemplate.apply(mpu.blobMetadata()); final ImmutableList<GoogleCloudStorageObject> objects = objectsBuilder.build(); if (!objects.isEmpty()) {
@Override public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) { ImmutableList.Builder<GoogleCloudStorageObject> objects = ImmutableList.builder(); for (MultipartPart part : parts) { objects.add(api.getObjectApi().getObject(mpu.containerName(), Strings2.urlEncode(getMPUPartName(mpu, part.partNumber())))); } ObjectTemplate destination = blobMetadataToObjectTemplate.apply(mpu.blobMetadata()); if (mpu.putOptions().getBlobAccess() == BlobAccess.PUBLIC_READ) { ObjectAccessControls controls = ObjectAccessControls.builder() .entity("allUsers") .bucket(mpu.containerName()) .role(READER) .build(); destination.addAcl(controls); } ComposeObjectTemplate template = ComposeObjectTemplate.builder() .fromGoogleCloudStorageObject(objects.build()) .destination(destination).build(); String eTag = api.getObjectApi().composeObjects(mpu.containerName(), Strings2.urlEncode(mpu.blobName()), template) .etag(); // remove parts, composite object keeps a reference to them ImmutableList.Builder<String> builder = ImmutableList.builder(); for (MultipartPart part : parts) { builder.add(getMPUPartName(mpu, part.partNumber())); } removeBlobs(mpu.containerName(), builder.build()); return eTag; }
@Override public MultipartPart uploadMultipartPart(MultipartUpload mpu, int partNumber, Payload payload) { String partName = getMPUPartName(mpu, partNumber); long partSize = payload.getContentMetadata().getContentLength(); InsertObjectOptions insertOptions = new InsertObjectOptions().name(partName); GoogleCloudStorageObject object = api.getObjectApi().simpleUpload(mpu.containerName(), mpu.blobMetadata().getContentMetadata().getContentType(), partSize, payload, insertOptions); return MultipartPart.create(partNumber, partSize, object.etag(), object.updated()); }
@Override public String completeMultipartUpload(final MultipartUpload mpu, final List<MultipartPart> parts) { long length = 0; for (MultipartPart part : parts) { length += part.partSize(); super.removeBlob(mpu.containerName(), mpu.id() + "-" + part.partNumber()); } byte[] array = Longs.toByteArray(length); ByteSourcePayload payload = new ByteSourcePayload( ByteSource.wrap(array)); payload.getContentMetadata().setContentLength((long) array.length); super.abortMultipartUpload(mpu); MultipartUpload mpu2 = super.initiateMultipartUpload( mpu.containerName(), mpu.blobMetadata(), mpu.putOptions()); MultipartPart part = super.uploadMultipartPart(mpu2, 1, payload); return super.completeMultipartUpload(mpu2, ImmutableList.of(part)); }