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


Java MultipartPart类代码示例

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


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

示例1: write

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
@Override
public HttpResponseOutputStream<List<MultipartPart>> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService())
        .getDetails(file, status);
    // ID for the initiated multipart upload.
    final MultipartUpload multipart;
    try {
        multipart = session.getClient().multipartStartUpload(
            containerService.getContainer(file).getName(), object);
        if(log.isDebugEnabled()) {
            log.debug(String.format("Multipart upload started for %s with ID %s",
                multipart.getObjectKey(), multipart.getUploadId()));
        }
    }
    catch(ServiceException e) {
        throw new S3ExceptionMappingService().map("Upload {0} failed", e, file);
    }
    final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status);
    return new HttpResponseOutputStream<List<MultipartPart>>(new MemorySegementingOutputStream(proxy,
        preferences.getInteger("s3.upload.multipart.partsize.minimum"))) {
        @Override
        public List<MultipartPart> getStatus() throws BackgroundException {
            return proxy.getCompleted();
        }
    };
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:27,代码来源:S3MultipartWriteFeature.java

示例2: append

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
/**
 * @return No Content-Range support
 */
@Override
public Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException {
    if(length >= preferences.getLong("s3.upload.multipart.threshold")) {
        if(preferences.getBoolean("s3.upload.multipart")) {
            try {
                final List<MultipartUpload> upload = multipartService.find(file);
                if(!upload.isEmpty()) {
                    Long size = 0L;
                    for(MultipartPart completed : multipartService.list(upload.iterator().next())) {
                        size += completed.getSize();
                    }
                    return new Append(size);
                }
            }
            catch(AccessDeniedException | InteroperabilityException e) {
                log.warn(String.format("Ignore failure listing incomplete multipart uploads. %s", e.getDetail()));
            }
        }
    }
    if(finder.withCache(cache).find(file)) {
        final PathAttributes attributes = this.attributes.withCache(cache).find(file);
        return new Append(false, true).withSize(attributes.getSize()).withChecksum(attributes.getChecksum());
    }
    return Write.notfound;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:29,代码来源:S3WriteFeature.java

示例3: list

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
@Override
public List<MultipartPart> list(final MultipartUpload multipart) throws BackgroundException {
    if(log.isInfoEnabled()) {
        log.info(String.format("List completed parts of %s", multipart.getUploadId()));
    }
    // This operation lists the parts that have been uploaded for a specific multipart upload.
    try {
        return session.getClient().multipartListParts(multipart);
    }
    catch(S3ServiceException e) {
        throw new S3ExceptionMappingService().map(MessageFormat.format("Upload {0} failed", multipart.getObjectKey()), e);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:S3DefaultMultipartService.java

示例4: submit

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
private Future<MultipartPart> submit(final Path source,
                                     final MultipartUpload multipart,
                                     final int partNumber, final long offset, final long length) throws BackgroundException {
    if(log.isInfoEnabled()) {
        log.info(String.format("Submit part %d of %s to queue with offset %d and length %d", partNumber, source, offset, length));
    }
    return pool.execute(new Callable<MultipartPart>() {
        @Override
        public MultipartPart call() throws BackgroundException {
            try {
                final HttpRange range = HttpRange.byLength(offset, length);
                final MultipartPart part = session.getClient().multipartUploadPartCopy(multipart, partNumber,
                        containerService.getContainer(source).getName(), containerService.getKey(source),
                        null, null, null, null, range.getStart(), range.getEnd(), source.attributes().getVersionId());
                if(log.isInfoEnabled()) {
                    log.info(String.format("Received response %s for part number %d", part, partNumber));
                }
                // Populate part with response data that is accessible via the object's metadata
                return new MultipartPart(partNumber,
                        null == part.getLastModified() ? new Date(System.currentTimeMillis()) : part.getLastModified(),
                        null == part.getEtag() ? StringUtils.EMPTY : part.getEtag(),
                        part.getSize());
            }
            catch(S3ServiceException e) {
                throw new S3ExceptionMappingService().map("Cannot copy {0}", e, source);
            }
        }
    });
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:30,代码来源:S3MultipartCopyFeature.java

示例5: testWrite

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
@Test
public void testWrite() throws Exception {
    final S3Session session = new S3Session(
            new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
                    )));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final CryptoWriteFeature feature = new CryptoWriteFeature<List<MultipartPart>>(session, new S3MultipartWriteFeature(session), cryptomator);
    final byte[] content = RandomUtils.nextBytes(6 * 1024 * 1024);
    final TransferStatus writeStatus = new TransferStatus();
    final Cryptor cryptor = cryptomator.getCryptor();
    final FileHeader header = cryptor.fileHeaderCryptor().create();
    writeStatus.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header));
    writeStatus.setNonces(new RandomNonceGenerator());
    writeStatus.setLength(-1L);
    final StatusOutputStream out = feature.write(test, writeStatus, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    final TransferStatus progress = new TransferStatus();
    new StreamCopier(new TransferStatus(), progress).transfer(in, out);
    assertEquals(content.length, progress.getOffset());
    assertNotNull(out.getStatus());
    assertTrue(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(test));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new CryptoReadFeature(session, new S3ReadFeature(session), cryptomator).read(test, new TransferStatus().length(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:39,代码来源:S3MultipartWriteFeatureTest.java

示例6: testWrite

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
@Test
public void testWrite() throws Exception {
    final S3Session session = new S3Session(
            new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
                    )));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final S3MultipartWriteFeature feature = new S3MultipartWriteFeature(session);
    final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume));
    final TransferStatus status = new TransferStatus();
    status.setLength(-1L);
    final Path file = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final HttpResponseOutputStream<List<MultipartPart>> out = feature.write(file, status, new DisabledConnectionCallback());
    final byte[] content = RandomUtils.nextBytes(6 * 1024 * 1024);
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    final TransferStatus progress = new TransferStatus();
    new StreamCopier(new TransferStatus(), progress).transfer(in, out);
    assertEquals(content.length, progress.getOffset());
    in.close();
    out.close();
    assertNotNull(out.getStatus());
    assertTrue(new S3FindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new S3ReadFeature(session).read(file, new TransferStatus().length(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:33,代码来源:S3MultipartWriteFeatureTest.java

示例7: testWriteZeroLength

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
@Test
public void testWriteZeroLength() throws Exception {
    final S3Session session = new S3Session(
            new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
                    )));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final S3MultipartWriteFeature feature = new S3MultipartWriteFeature(session);
    final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume));
    final byte[] content = RandomUtils.nextBytes(0);
    final TransferStatus status = new TransferStatus();
    status.setLength(-1L);
    final Path file = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final HttpResponseOutputStream<List<MultipartPart>> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    assertEquals(content.length, IOUtils.copyLarge(in, out));
    in.close();
    out.close();
    assertNotNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new S3ReadFeature(session).read(file, new TransferStatus().length(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:30,代码来源:S3MultipartWriteFeatureTest.java

示例8: copyLargeFile

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
public void copyLargeFile(S3Object srcObject, String dstKey) throws IOException {
  try {
    long partCount = srcObject.getContentLength() / multipartCopyBlockSize +
        (srcObject.getContentLength() % multipartCopyBlockSize > 0 ? 1 : 0);

    MultipartUpload multipartUpload = s3Service.multipartStartUpload
        (bucket.getName(), dstKey, srcObject.getMetadataMap());

    List<MultipartPart> listedParts = new ArrayList<MultipartPart>();
    for (int i = 0; i < partCount; i++) {
      long byteRangeStart = i * multipartCopyBlockSize;
      long byteLength;
      if (i < partCount - 1) {
        byteLength = multipartCopyBlockSize;
      } else {
        byteLength = srcObject.getContentLength() % multipartCopyBlockSize;
        if (byteLength == 0) {
          byteLength = multipartCopyBlockSize;
        }
      }

      MultipartPart copiedPart = s3Service.multipartUploadPartCopy
          (multipartUpload, i + 1, bucket.getName(), srcObject.getKey(),
           null, null, null, null, byteRangeStart,
           byteRangeStart + byteLength - 1, null);
      listedParts.add(copiedPart);
    }
    
    Collections.reverse(listedParts);
    s3Service.multipartCompleteUpload(multipartUpload, listedParts);
  } catch (ServiceException e) {
    handleException(e, srcObject.getKey());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:Jets3tNativeFileSystemStore.java

示例9: multipartUploadPartCopyImpl

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
protected abstract MultipartPart multipartUploadPartCopyImpl(String uploadId,
String targetBucketName, String targetObjectKey, Integer partNumber,
String sourceBucketName, String sourceObjectKey,
Calendar ifModifiedSince, Calendar ifUnmodifiedSince,
String[] ifMatchTags, String[] ifNoneMatchTags,
Long byteRangeStart, Long byteRangeEnd,
String versionId) throws S3ServiceException;
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:8,代码来源:S3Service.java

示例10: multipartListPartsImpl

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
@Override
protected List<MultipartPart> multipartListPartsImpl(String uploadId,
    String bucketName, String objectKey) throws S3ServiceException
{
    Map<String, String> requestParameters = new HashMap<String, String>();
    requestParameters.put("uploadId", uploadId);
    requestParameters.put("max-parts", "1000");

    try {
        List<MultipartPart> parts = new ArrayList<MultipartPart>();
        String nextPartNumberMarker = null;
        boolean incompleteListing = true;
        do {
            if (nextPartNumberMarker != null) {
                requestParameters.put("part-number-marker", nextPartNumberMarker);
            } else {
                requestParameters.remove("part-number-marker");
            }

            HttpResponse httpResponse = performRestGet(bucketName, objectKey, requestParameters, null);
            ListMultipartPartsResultHandler handler = getXmlResponseSaxParser()
                .parseListMultipartPartsResult(
                    new HttpMethodReleaseInputStream(httpResponse));
            parts.addAll(handler.getMultipartPartList());

            incompleteListing = handler.isTruncated();
            nextPartNumberMarker = handler.getNextPartNumberMarker();

            // Sanity check for valid pagination values.
            if (incompleteListing && nextPartNumberMarker == null)
            {
                throw new ServiceException("Unable to retrieve paginated "
                    + "ListMultipartPartsResult without valid NextKeyMarker value.");
            }
        } while (incompleteListing);
        return parts;
    } catch (ServiceException se) {
        throw new S3ServiceException(se);
    }
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:41,代码来源:RestS3Service.java

示例11: parseMultipartUploadPartCopyResult

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
public MultipartPart parseMultipartUploadPartCopyResult(InputStream inputStream)
    throws ServiceException
{
    MultipartPartResultHandler handler = new MultipartPartResultHandler(xr);
    parseXmlInputStream(handler, sanitizeXmlDocument(handler, inputStream));
    return handler.getMultipartPart();
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:8,代码来源:XmlResponsesSaxParser.java

示例12: copyLargeFile

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
public void copyLargeFile(S3Object srcObject, String dstKey) throws IOException {
  try {
    long partCount = srcObject.getContentLength() / multipartCopyBlockSize +
        (srcObject.getContentLength() % multipartCopyBlockSize > 0 ? 1 : 0);

    MultipartUpload multipartUpload = s3Service.multipartStartUpload
        (bucket.getName(), dstKey, srcObject.getMetadataMap());

    List<MultipartPart> listedParts = new ArrayList<MultipartPart>();
    for (int i = 0; i < partCount; i++) {
      long byteRangeStart = i * multipartCopyBlockSize;
      long byteLength;
      if (i < partCount - 1) {
        byteLength = multipartCopyBlockSize;
      } else {
        byteLength = srcObject.getContentLength() % multipartCopyBlockSize;
        if (byteLength == 0) {
          byteLength = multipartCopyBlockSize;
        }
      }

      MultipartPart copiedPart = s3Service.multipartUploadPartCopy
          (multipartUpload, i + 1, bucket.getName(), srcObject.getKey(),
           null, null, null, null, byteRangeStart,
           byteRangeStart + byteLength - 1, null);
      listedParts.add(copiedPart);
    }
    
    Collections.reverse(listedParts);
    s3Service.multipartCompleteUpload(multipartUpload, listedParts);
  } catch (ServiceException e) {
    handleServiceException(e);
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:35,代码来源:Jets3tNativeFileSystemStore.java

示例13: getCompleted

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
public List<MultipartPart> getCompleted() {
    return completed;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:4,代码来源:S3MultipartWriteFeature.java

示例14: submit

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
private Future<MultipartPart> submit(final ThreadPool pool, final Path file, final Local local,
                                     final BandwidthThrottle throttle, final StreamListener listener,
                                     final TransferStatus overall, final MultipartUpload multipart,
                                     final int partNumber, final long offset, final long length, final ConnectionCallback callback) throws BackgroundException {
    if(log.isInfoEnabled()) {
        log.info(String.format("Submit part %d of %s to queue with offset %d and length %d", partNumber, file, offset, length));
    }
    return pool.execute(new DefaultRetryCallable<MultipartPart>(new BackgroundExceptionCallable<MultipartPart>() {
        @Override
        public MultipartPart call() throws BackgroundException {
            if(overall.isCanceled()) {
                throw new ConnectionCanceledException();
            }
            final Map<String, String> requestParameters = new HashMap<String, String>();
            requestParameters.put("uploadId", multipart.getUploadId());
            requestParameters.put("partNumber", String.valueOf(partNumber));
            final TransferStatus status = new TransferStatus()
                    .length(length)
                    .skip(offset)
                    .withParameters(requestParameters);
            status.setHeader(overall.getHeader());
            status.setNonces(overall.getNonces());
            switch(session.getSignatureVersion()) {
                case AWS4HMACSHA256:
                    status.setChecksum(writer.checksum(file)
                            .compute(StreamCopier.skip(new BoundedInputStream(local.getInputStream(), offset + length), offset), status)
                    );
                    break;
            }
            status.setSegment(true);
            final StorageObject part = S3MultipartUploadService.super.upload(
                    file, local, throttle, listener, status, overall, new StreamProgress() {
                        @Override
                        public void progress(final long bytes) {
                            status.progress(bytes);
                            // Discard sent bytes in overall progress if there is an error reply for segment.
                            overall.progress(bytes);
                        }

                        @Override
                        public void setComplete() {
                            status.setComplete();
                        }
                    }, callback);
            if(log.isInfoEnabled()) {
                log.info(String.format("Received response %s for part number %d", part, partNumber));
            }
            // Populate part with response data that is accessible via the object's metadata
            return new MultipartPart(partNumber,
                    null == part.getLastModifiedDate() ? new Date(System.currentTimeMillis()) : part.getLastModifiedDate(),
                    null == part.getETag() ? StringUtils.EMPTY : part.getETag(),
                    part.getContentLength());

        }
    }, overall));
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:57,代码来源:S3MultipartUploadService.java

示例15: list

import org.jets3t.service.model.MultipartPart; //导入依赖的package包/类
@Override
public List<MultipartPart> list(final MultipartUpload multipart) throws BackgroundException {
    return Collections.emptyList();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:5,代码来源:S3DisabledMultipartService.java


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