当前位置: 首页>>代码示例>>Java>>正文


Java MultipartPart类代码示例

本文整理汇总了Java中org.jclouds.blobstore.domain.MultipartPart的典型用法代码示例。如果您正苦于以下问题:Java MultipartPart类的具体用法?Java MultipartPart怎么用?Java MultipartPart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MultipartPart类属于org.jclouds.blobstore.domain包,在下文中一共展示了MultipartPart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadMultipartPart

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public MultipartPart uploadMultipartPart(MultipartUpload mpu,
        int partNumber, Payload payload) {
    long length;
    try (InputStream is = payload.openStream()) {
        length = ByteStreams.copy(is, ByteStreams.nullOutputStream());
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    byte[] array = Longs.toByteArray(length);
    ByteSourcePayload newPayload = new ByteSourcePayload(
            ByteSource.wrap(array));
    newPayload.setContentMetadata(payload.getContentMetadata());
    newPayload.getContentMetadata().setContentLength((long) array.length);
    newPayload.getContentMetadata().setContentMD5((HashCode) null);

    MultipartPart part = super.uploadMultipartPart(mpu, partNumber,
            newPayload);
    return MultipartPart.create(part.partNumber(), length, part.partETag(),
            part.lastModified());
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:23,代码来源:NullBlobStore.java

示例2: completeMultipartUpload

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public String completeMultipartUpload(final MultipartUpload mpu,
        final List<MultipartPart> parts) {
    schedule(new Callable<String>() {
            @Override
            public String call() {
                String farETag = delegate().completeMultipartUpload(mpu,
                        parts);
                return farETag;
            }
        });
    return "";  // TODO: fake ETag
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:14,代码来源:EventualBlobStore.java

示例3: uploadMultipartPart

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public MultipartPart uploadMultipartPart(MultipartUpload mpu,
        int partNumber, Payload payload) {
    MultipartPart part = delegate().uploadMultipartPart(mpu, partNumber,
            payload);
    return part;
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:8,代码来源:EventualBlobStore.java

示例4: listMultipartUpload

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public List<MultipartPart> listMultipartUpload(MultipartUpload mpu) {
    ImmutableList.Builder<MultipartPart> builder = ImmutableList.builder();
    for (MultipartPart part : super.listMultipartUpload(mpu)) {
        builder.add(MultipartPart.create(part.partNumber(), 0,
                part.partETag(), part.lastModified()));
    }
    return builder.build();
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:10,代码来源:NullBlobStore.java

示例5: testReadAfterMultipartUpload

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Test
public void testReadAfterMultipartUpload() throws Exception {
    String blobName = createRandomBlobName();
    Blob blob = makeBlob(eventualBlobStore, blobName);
    MultipartUpload mpu = eventualBlobStore.initiateMultipartUpload(
            containerName, blob.getMetadata(), new PutOptions());
    MultipartPart part = eventualBlobStore.uploadMultipartPart(mpu,
            /*partNumber=*/ 1, blob.getPayload());
    eventualBlobStore.completeMultipartUpload(mpu, ImmutableList.of(part));
    assertThat(eventualBlobStore.getBlob(containerName, blobName))
            .isNull();
    delay();
    validateBlob(eventualBlobStore.getBlob(containerName, blobName));
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:15,代码来源:EventualBlobStoreTest.java

示例6: handlePut

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public void handlePut(HttpExchange request, Map<String, String> params) throws IOException {
    if (!params.containsKey("upload")) {
        Util.sendNotFound("Upload", params.get("upload"), request);
        return;
    }

    for (String header : REQUIRED_PUT_HEADERS) {
        if (!request.getRequestHeaders().containsKey(header)) {
            Util.sendBadRequest(String.format("Header %s not found", header), request);
            return;
        }
    }

    UUID uploadId = UUID.fromString(params.get("upload"));
    Upload upload = proxy.getUpload(params.get("vault"), uploadId);
    if (upload == null) {
        Util.sendNotFound("Upload", params.get("upload"), request);
        return;
    }
    Matcher rangeMatcher = CONTENT_RANGE_RE.matcher(request.getRequestHeaders().getFirst("Content-Range"));
    if (!rangeMatcher.matches()) {
        Util.sendBadRequest("Invalid content range", request);
        return;
    }
    String startRangeString = rangeMatcher.group("start");
    String endRangeString = rangeMatcher.group("end");
    long start;
    long end;
    try {
        start = Long.parseLong(startRangeString);
        end = Long.parseLong(endRangeString);
    } catch (NumberFormatException e) {
        Util.sendBadRequest("Invalid range", request);
        return;
    }
    long size = end - start + 1;
    if (size > upload.partSize) {
        Util.sendBadRequest(String.format("Part size must be smaller than %s", upload.partSize), request);
        return;
    }

    if (start % upload.partSize != 0) {
        Util.sendBadRequest(String.format("Starting part range does not align %d", start), request);
        return;
    }

    if (upload.parts.size() > 10000) {
        Util.sendBadRequest("Cannot have more than 10000 parts", request);
        return;
    }

    // parts are 1-indexed
    int partNumber = (int) (start/upload.partSize + 1);

    Payload payload = Payloads.newInputStreamPayload(request.getRequestBody());
    MultipartPart uploadedPart = proxy.getBlobStore().uploadMultipartPart(upload.jcloudsUpload, partNumber,
            payload);
    if (uploadedPart == null) {
        Util.sendServerError("Failed to save the part", request);
        return;
    }
    String sha256TreeHash = request.getRequestHeaders().getFirst("x-amz-sha256-tree-hash");
    upload.parts.add(new UploadPart(sha256TreeHash, size));

    request.getResponseHeaders().put("x-amz-sha256-tree-hash",
            request.getRequestHeaders().get("x-amz-sha256-tree-hash"));
    request.sendResponseHeaders(Response.Status.NO_CONTENT.getStatusCode(), -1);
}
 
开发者ID:bouncestorage,项目名称:glacier-proxy,代码行数:70,代码来源:Multipart.java

示例7: completeMultipartUpload

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public String completeMultipartUpload(final MultipartUpload mpu,
        final List<MultipartPart> parts) {
    throw new UnsupportedOperationException("read-only BlobStore");
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:6,代码来源:ReadOnlyBlobStore.java

示例8: uploadMultipartPart

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public MultipartPart uploadMultipartPart(MultipartUpload mpu,
        int partNumber, Payload payload) {
    throw new UnsupportedOperationException("read-only BlobStore");
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:6,代码来源:ReadOnlyBlobStore.java

示例9: testCreateMultipartBlobGetBlob

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Test
public void testCreateMultipartBlobGetBlob() throws Exception {
    String blobName = "multipart-upload";
    BlobMetadata blobMetadata = makeBlob(nullBlobStore, blobName)
            .getMetadata();
    MultipartUpload mpu = nullBlobStore.initiateMultipartUpload(
            containerName, blobMetadata, new PutOptions());

    ByteSource byteSource = TestUtils.randomByteSource().slice(
            0, nullBlobStore.getMinimumMultipartPartSize() + 1);
    ByteSource byteSource1 = byteSource.slice(
            0, nullBlobStore.getMinimumMultipartPartSize());
    ByteSource byteSource2 = byteSource.slice(
            nullBlobStore.getMinimumMultipartPartSize(), 1);
    Payload payload1 = Payloads.newByteSourcePayload(byteSource1);
    Payload payload2 = Payloads.newByteSourcePayload(byteSource2);
    payload1.getContentMetadata().setContentLength(byteSource1.size());
    payload2.getContentMetadata().setContentLength(byteSource2.size());
    MultipartPart part1 = nullBlobStore.uploadMultipartPart(mpu, 1,
            payload1);
    MultipartPart part2 = nullBlobStore.uploadMultipartPart(mpu, 2,
            payload2);

    List<MultipartPart> parts = nullBlobStore.listMultipartUpload(mpu);
    assertThat(parts.get(0).partNumber()).isEqualTo(1);
    assertThat(parts.get(0).partSize()).isZero();
    assertThat(parts.get(0).partETag()).isEqualTo(part1.partETag());
    assertThat(parts.get(1).partNumber()).isEqualTo(2);
    assertThat(parts.get(1).partSize()).isZero();
    assertThat(parts.get(1).partETag()).isEqualTo(part2.partETag());

    nullBlobStore.completeMultipartUpload(mpu, ImmutableList.of(part1,
            part2));

    Blob newBlob = nullBlobStore.getBlob(containerName, blobName);
    validateBlobMetadata(newBlob.getMetadata(), byteSource);

    // content differs, only compare length
    try (InputStream actual = newBlob.getPayload().openStream();
            InputStream expected = byteSource.openStream()) {
        long actualLength = ByteStreams.copy(actual,
                ByteStreams.nullOutputStream());
        long expectedLength = ByteStreams.copy(expected,
                ByteStreams.nullOutputStream());
        assertThat(actualLength).isEqualTo(expectedLength);
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:48,代码来源:NullBlobStoreTest.java

示例10: completeMultipartUpload

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
default String completeMultipartUpload(MultipartUpload multipartUpload, List<MultipartPart> list) {
    return delegate().completeMultipartUpload(multipartUpload, list);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:5,代码来源:IForwardingBlobStore.java

示例11: uploadMultipartPart

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
default MultipartPart uploadMultipartPart(MultipartUpload multipartUpload, int i, Payload payload) {
    return delegate().uploadMultipartPart(multipartUpload, i, payload);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:5,代码来源:IForwardingBlobStore.java

示例12: listMultipartUpload

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
default List<MultipartPart> listMultipartUpload(MultipartUpload multipartUpload) {
    return delegate().listMultipartUpload(multipartUpload);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:5,代码来源:IForwardingBlobStore.java

示例13: completeMultipartUpload

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public String completeMultipartUpload(MultipartUpload multipartUpload, List<MultipartPart> list) {
    throw new UnsupportedOperationException();
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:5,代码来源:EncryptedBlobStore.java

示例14: uploadMultipartPart

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public MultipartPart uploadMultipartPart(MultipartUpload multipartUpload, int i, Payload payload) {
    throw new UnsupportedOperationException();
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:5,代码来源:EncryptedBlobStore.java

示例15: listMultipartUpload

import org.jclouds.blobstore.domain.MultipartPart; //导入依赖的package包/类
@Override
public List<MultipartPart> listMultipartUpload(MultipartUpload multipartUpload) {
    throw new UnsupportedOperationException();
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:5,代码来源:EncryptedBlobStore.java


注:本文中的org.jclouds.blobstore.domain.MultipartPart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。