• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UploadResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testS3Persister

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Test
public void testS3Persister() throws Exception {
    Upload upload = mock(Upload.class);
    when(upload.waitForUploadResult()).thenReturn(new UploadResult());
    TransferManager transferManager = mock(TransferManager.class);
    when(transferManager.upload(anyString(), anyString(), any())).thenReturn(upload);

    S3Persister s3Persister = new S3Persister(transferManager, "foo");
    s3Persister.saveMetrics("foo", "bar");

    verify(transferManager, times(1)).upload(anyString(), anyString(), any());
    verify(transferManager, times(1)).shutdownNow();
    verifyNoMoreInteractions(transferManager);
    verify(upload, times(1)).waitForCompletion();
    verifyNoMoreInteractions(upload);
    assertFalse(new File("foo").exists());
}
 
开发者ID:awslabs,项目名称:emr-workload-profiler,代码行数:18,代码来源:S3PersisterTest.java


示例2: create

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
/**
 * Constructs a new upload watcher and then immediately submits it to
 * the thread pool.
 *
 * @param manager
 *            The {@link TransferManager} that owns this upload.
 * @param transfer
 *            The transfer being processed.
 * @param threadPool
 *            The {@link ExecutorService} to which we should submit new
 *            tasks.
 * @param multipartUploadCallable
 *            The callable responsible for processing the upload
 *            asynchronously
 * @param putObjectRequest
 *            The original putObject request
 * @param progressListenerChain
 *            A chain of listeners that wish to be notified of upload
 *            progress
 */
public static UploadMonitor create(
        TransferManager manager,
        UploadImpl transfer,
        ExecutorService threadPool,
        UploadCallable multipartUploadCallable,
        PutObjectRequest putObjectRequest,
        ProgressListenerChain progressListenerChain) {

    UploadMonitor uploadMonitor = new UploadMonitor(manager, transfer,
            threadPool, multipartUploadCallable, putObjectRequest,
            progressListenerChain);
    Future<UploadResult> thisFuture = threadPool.submit(uploadMonitor);
    // Use an atomic compareAndSet to prevent a possible race between the
    // setting of the UploadMonitor's futureReference, and setting the
    // CompleteMultipartUpload's futureReference within the call() method.
    // We only want to set the futureReference to UploadMonitor's futureReference if the
    // current value is null, otherwise the futureReference that's set is
    // CompleteMultipartUpload's which is ultimately what we want.
    uploadMonitor.futureReference.compareAndSet(null, thisFuture);
    return uploadMonitor;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:42,代码来源:UploadMonitor.java


示例3: shouldUploadInParallel

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
/**
 * Tests if an object can be uploaded asynchronously
 *
 * @throws Exception not expected
 */
@Test
public void shouldUploadInParallel() throws Exception {
  final File uploadFile = new File(UPLOAD_FILE_NAME);

  s3Client.createBucket(BUCKET_NAME);

  final TransferManager transferManager = createDefaultTransferManager();
  final Upload upload =
      transferManager.upload(new PutObjectRequest(BUCKET_NAME, UPLOAD_FILE_NAME, uploadFile));
  final UploadResult uploadResult = upload.waitForUploadResult();

  assertThat(uploadResult.getKey(), equalTo(UPLOAD_FILE_NAME));

  final S3Object getResult = s3Client.getObject(BUCKET_NAME, UPLOAD_FILE_NAME);
  assertThat(getResult.getKey(), equalTo(UPLOAD_FILE_NAME));
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:22,代码来源:AmazonClientUploadIT.java


示例4: upload

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Test
@Ignore
@Repeat(times = 1, threads = 4)
public void upload() {
    S3ObjectWriter writerWithoutEncryption = buildWriterWithEncryption(false);
    long startNE = System.currentTimeMillis();
    Try<UploadResult, Throwable> uploadWithoutEncryption = writerWithoutEncryption.putSync("uploadWithoutEncryption" + r.nextLong(), nullableFile.get());
    long endNE = System.currentTimeMillis();
    assertTrue(uploadWithoutEncryption.isSuccess());
    unencryptedHist.update(endNE - startNE);

    S3ObjectWriter writerWithEncryption = buildWriterWithEncryption(true);
    long startWE = System.currentTimeMillis();
    Try<UploadResult, Throwable> uploadWithEncryption = writerWithEncryption.putSync("uploadWithEncryption" + r.nextLong(), nullableFile.get());
    assertTrue(uploadWithEncryption.isSuccess());
    long endWE = System.currentTimeMillis();
    aes256Hist.update(endWE - startWE);
    
    
}
 
开发者ID:aol,项目名称:micro-server,代码行数:21,代码来源:S3UploadSystemTest.java


示例5: verifyMultiPartUpload

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
private Map<String, String> verifyMultiPartUpload(MultipleFileUpload uploadDirectory) throws AmazonClientException {
    Collection<? extends Upload> uploadResults = uploadDirectory.getSubTransfers();
    Iterator<? extends Upload> iterator = uploadResults.iterator();

    Map<String, String> fileModifyMap = new HashMap<String, String>();
    while (iterator.hasNext()) {
        UploadResult uploadResult = null;

        try {
            uploadResult = iterator.next().waitForUploadResult();
        } catch (Exception e) {
                LOGGER.error(e.getMessage());
                throw new AmazonClientException(e.getMessage());
        }

        if (uploadResult != null) {
            LOGGER.info(String.format("Multipart upload success for file " + uploadResult.getKey() + " to Amazon S3 bucket " + uploadResult.getBucketName()));
        }
    }
    
    return fileModifyMap;
}
 
开发者ID:ktenzer,项目名称:snap2cloud,代码行数:23,代码来源:S3Backup.java


示例6: put

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Override
public void put(String uri, File f) throws AmazonClientException {
    LOG.trace("Uploading " + uri);
    String[] parts = pieces(uri);
    ObjectMetadata om = new ObjectMetadata();
    om.setContentLength(f.length());
    if (f.getName().endsWith("gzip")) {
        om.setContentEncoding("gzip");
    }
    uploadsInProgress.incrementAndGet();
    try {
        PutObjectRequest req = new PutObjectRequest(parts[0],parts[1],f);
        req.setMetadata(om);
        UploadResult resp = svc.upload(req).waitForUploadResult();
        LOG.trace("Uploaded " + uri + " with ETag " + resp.getETag());
    } catch (InterruptedException ie) {
        LOG.error("Interrupted while uploading {} to {}.",
                f.getPath(), uri);
        throw Throwables.propagate(ie);
    } finally {
        uploadsInProgress.decrementAndGet();
    }
}
 
开发者ID:Multifarious,项目名称:skid-road,代码行数:24,代码来源:AwsS3ClientStorage.java


示例7: before

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@BeforeEach
void before() {
	doAnswer(invocationOnMock -> {
		Runnable method = invocationOnMock.getArgument(0);
		CompletableFuture.runAsync(method);
		return null;
	}).when(taskExecutor).execute(any(Runnable.class));

	result = new UploadResult();
	result.setKey("meep");
	when(transferManager.upload(any(PutObjectRequest.class))).thenReturn(upload);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:13,代码来源:StorageServiceImplTest.java


示例8: testPersistApplicationNullException

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Test(expectedExceptions = RuntimeException.class)
public void testPersistApplicationNullException() throws Exception {
    Upload upload = mock(Upload.class);
    when(upload.waitForUploadResult()).thenReturn(new UploadResult());
    TransferManager transferManager = mock(TransferManager.class);
    when(transferManager.upload(anyString(), anyString(), any())).thenReturn(upload);

    S3Persister s3Persister = new S3Persister(transferManager, "foo");

    try {
        s3Persister.saveMetrics("foo", null);
    } finally {
        assertFalse(new File("foo").exists());
    }
}
 
开发者ID:awslabs,项目名称:emr-workload-profiler,代码行数:16,代码来源:S3PersisterTest.java


示例9: call

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Override
public UploadResult call() throws Exception {
    CompleteMultipartUploadResult res;

    try {
        CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest(
                origReq.getBucketName(), origReq.getKey(), uploadId,
                collectPartETags())
                .withRequesterPays(origReq.isRequesterPays())
            .withGeneralProgressListener(origReq.getGeneralProgressListener())
            .withRequestMetricCollector(origReq.getRequestMetricCollector())
            ;
        res = s3.completeMultipartUpload(req);
    } catch (Exception e) {
        publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
        throw e;
    }

    UploadResult uploadResult = new UploadResult();
    uploadResult.setBucketName(origReq
            .getBucketName());
    uploadResult.setKey(origReq.getKey());
    uploadResult.setETag(res.getETag());
    uploadResult.setVersionId(res.getVersionId());

    monitor.uploadComplete();

    return uploadResult;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:30,代码来源:CompleteMultipartUpload.java


示例10: call

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
public UploadResult call() throws Exception {
    upload.setState(TransferState.InProgress);
    if ( isMultipartUpload() ) {
        publishProgress(listener, ProgressEventType.TRANSFER_STARTED_EVENT);
        return uploadInParts();
    } else {
        return uploadInOneChunk();
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:10,代码来源:UploadCallable.java


示例11: uploadInOneChunk

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
/**
 * Uploads the given request in a single chunk and returns the result.
 */
private UploadResult uploadInOneChunk() {
    PutObjectResult putObjectResult = s3.putObject(origReq);

    UploadResult uploadResult = new UploadResult();
    uploadResult.setBucketName(origReq.getBucketName());
    uploadResult.setKey(origReq.getKey());
    uploadResult.setETag(putObjectResult.getETag());
    uploadResult.setVersionId(putObjectResult.getVersionId());
    return uploadResult;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:UploadCallable.java


示例12: uploadPartsInSeries

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
/**
 * Uploads all parts in the request in serial in this thread, then completes
 * the upload and returns the result.
 */
private UploadResult uploadPartsInSeries(UploadPartRequestFactory requestFactory) {

    final List<PartETag> partETags = new ArrayList<PartETag>();

    while (requestFactory.hasMoreRequests()) {
        if (threadPool.isShutdown()) throw new CancellationException("TransferManager has been shutdown");
        UploadPartRequest uploadPartRequest = requestFactory.getNextUploadPartRequest();
        // Mark the stream in case we need to reset it
        InputStream inputStream = uploadPartRequest.getInputStream();
        if (inputStream != null && inputStream.markSupported()) {
            if (uploadPartRequest.getPartSize() >= Integer.MAX_VALUE) {
                inputStream.mark(Integer.MAX_VALUE);
            } else {
                inputStream.mark((int)uploadPartRequest.getPartSize());
            }
        }
        partETags.add(s3.uploadPart(uploadPartRequest).getPartETag());
    }

    CompleteMultipartUploadRequest req =
        new CompleteMultipartUploadRequest(
            origReq.getBucketName(), origReq.getKey(), multipartUploadId,
                partETags)
                .withRequesterPays(origReq.isRequesterPays())
        .withGeneralProgressListener(origReq.getGeneralProgressListener())
        .withRequestMetricCollector(origReq.getRequestMetricCollector())
        ;
    CompleteMultipartUploadResult res = s3.completeMultipartUpload(req);

    UploadResult uploadResult = new UploadResult();
    uploadResult.setBucketName(res.getBucketName());
    uploadResult.setKey(res.getKey());
    uploadResult.setETag(res.getETag());
    uploadResult.setVersionId(res.getVersionId());
    return uploadResult;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:41,代码来源:UploadCallable.java


示例13: multipartCopy

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
/**
 * Verifies multipart copy.
 *
 * @throws InterruptedException
 */
@Test
public void multipartCopy() throws InterruptedException, IOException, NoSuchAlgorithmException {
  final int contentLen = 3 * _1MB;

  final ObjectMetadata objectMetadata = new ObjectMetadata();
  objectMetadata.setContentLength(contentLen);

  final String assumedSourceKey = UUID.randomUUID().toString();

  final Bucket sourceBucket = s3Client.createBucket(UUID.randomUUID().toString());
  final Bucket targetBucket = s3Client.createBucket(UUID.randomUUID().toString());

  final TransferManager transferManager = createTransferManager(_2MB, _1MB, _2MB, _1MB);

  final InputStream sourceInputStream = randomInputStream(contentLen);
  final Upload upload = transferManager
      .upload(sourceBucket.getName(), assumedSourceKey,
          sourceInputStream, objectMetadata);

  final UploadResult uploadResult = upload.waitForUploadResult();

  assertThat(uploadResult.getKey(), is(assumedSourceKey));

  final String assumedDestinationKey = UUID.randomUUID().toString();
  final Copy copy =
      transferManager.copy(sourceBucket.getName(), assumedSourceKey, targetBucket.getName(),
          assumedDestinationKey);
  final CopyResult copyResult = copy.waitForCopyResult();
  assertThat(copyResult.getDestinationKey(), is(assumedDestinationKey));

  final S3Object copiedObject = s3Client.getObject(targetBucket.getName(), assumedDestinationKey);

  assertThat("Hashes for source and target S3Object do not match.",
      HashUtil.getDigest(copiedObject.getObjectContent()) + "-1",
      is(uploadResult.getETag()));
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:42,代码来源:AmazonClientUploadIT.java


示例14: upload

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Override
public void upload(String bucketName, String name, InputStream input, ObjectMetadata meta) throws IOException {
    final Upload myUpload = tx.upload(bucketName, name, input, meta);
    try {
        UploadResult uploadResult = myUpload.waitForUploadResult();
        LOG.info("Upload completed, bucket={}, key={}", uploadResult.getBucketName(), uploadResult.getKey());
    } catch (InterruptedException e) {
        throw new IOException(e);
    }
}
 
开发者ID:wurstmeister,项目名称:storm-s3,代码行数:11,代码来源:BlockingTransferManagerUploader.java


示例15: testAggregateEventsToS3

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Test
@Ignore
public void testAggregateEventsToS3() throws IOException, InterruptedException {
	// Set up mock expectations
	final Capture<File> fileCapture = new Capture<>();
	final BooleanHolder fileAssertionsRan = new BooleanHolder();
	EasyMock.expect(mockTransferManager.upload(EasyMock.eq("local.build.bucket"), EasyMock.eq(streamFileName), EasyMock.capture(fileCapture))).andReturn(mockUpload);
	EasyMock.expect(mockUpload.waitForUploadResult()).andAnswer(new IAnswer<UploadResult>() {
		@Override
		public UploadResult answer() throws Throwable {
			// Run temp file assertions before it's deleted
			File capturedFile = fileCapture.getValue();
			Assert.assertNotNull(capturedFile);
			String capturedEventStream = replaceDates(fileToString(capturedFile));
			Assert.assertNotNull(capturedEventStream);
			Assert.assertEquals("Line count", 3, capturedEventStream.split("\n").length);
			Assert.assertEquals("DATE INFO  org.ihtsdo.telemetry.server.TestProcessor.doProcessing - Start of event stream\n" +
					"DATE INFO  org.ihtsdo.telemetry.server.TestProcessor.doProcessing - Processing...\n" +
					"DATE INFO  org.ihtsdo.telemetry.server.TestProcessor.doProcessing - End of event stream\n",
					capturedEventStream);
			fileAssertionsRan.b = true;
			return null;
		}
	});
	mocksControl.replay();

	// Perform test scenario
	TestProcessor.doProcessing(TelemetryProcessorTest.streamS3Destination);
	// Wait for the aggregator to finish.
	Thread.sleep(1000);

	// Assert mock expectations
	mocksControl.verify();
	Assert.assertTrue(fileAssertionsRan.b);
}
 
开发者ID:IHTSDO,项目名称:snomed-release-service,代码行数:36,代码来源:TelemetryProcessorTest.java


示例16: dump

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
public static void dump(UploadResult ur, Log log) {
    int width = "VersionId".length();
    log.info("  Bucket    : " + ur.getBucketName());
    log.info("  Key       : " + ur.getKey());
    log.info("  ETag      : " + ur.getETag());
    log.info("  VersionId : " + ur.getVersionId());
}
 
开发者ID:pglass,项目名称:awspush-maven-plugin,代码行数:8,代码来源:Util.java


示例17: doInBackground

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Override
protected UploadResult doInBackground(String... mediaPaths) {
    UploadResult result = null;

    if(null == mediaPaths[0]) {
        jobFailed(null, 7000000, "S3 media path is null");
        return result;
    }

    File mediaFile = new File(mediaPaths[0]);
    if (!mediaFile.exists()) {
        jobFailed(null, 7000001, "S3 media path invalid");
        return result;
    }

    try {
        final AWSCredentials credentials = new BasicAWSCredentials(mContext.getString(R.string.s3_key), mContext.getString(R.string.s3_secret));
        Log.i(TAG, "upload file: " + mediaFile.getName());

        AmazonS3Client s3Client = new AmazonS3Client(credentials, s3Config);
        TransferManager transferManager = new TransferManager(s3Client);
        Upload upload = transferManager.upload(bucket, pathPrefix + mediaFile.getName(), mediaFile);

        result = upload.waitForUploadResult();
    } catch (Exception e) {
        Timber.e("upload error: " + e.getMessage());
        jobFailed(null, 7000002, "S3 upload failed: " + e.getMessage());
    }

    return result;
}
 
开发者ID:StoryMaker,项目名称:SecureShareLib,代码行数:32,代码来源:S3SiteController.java


示例18: onPostExecute

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
@Override
protected void onPostExecute(UploadResult result) {
    if(null != result) {
        Log.i(TAG, "upload result: " + result.getKey());
        String url = "https://s3-us-west-1.amazonaws.com/" + bucket + "/" + result.getKey();
        jobSucceeded(url);
    } else {
        jobFailed(null, 7000002, "S3 upload failed: PostExecute");
    }
}
 
开发者ID:StoryMaker,项目名称:SecureShareLib,代码行数:11,代码来源:S3SiteController.java


示例19: getFuture

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
public Future<UploadResult> getFuture() {
    return futureReference.get();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:4,代码来源:UploadMonitor.java


示例20: get

import com.amazonaws.services.s3.transfer.model.UploadResult; //导入依赖的package包/类
public UploadResult get() throws Exception {
    return mUpload.waitForUploadResult();
}
 
开发者ID:pinterest,项目名称:secor,代码行数:4,代码来源:S3UploadHandle.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ZuulProperties类代码示例发布时间:2022-05-21
下一篇:
Java Try类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap