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


Java PutOptions类代码示例

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


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

示例1: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(final String containerName, Blob blob,
        final PutOptions options) {
    final String nearName = blob.getMetadata().getName();
    String nearETag = writeStore.putBlob(containerName, blob, options);
    schedule(new Callable<String>() {
            @Override
            public String call() {
                Blob nearBlob = writeStore.getBlob(containerName, nearName);
                String farETag = delegate().putBlob(containerName,
                        nearBlob, options);
                return farETag;
            }
        });
    return nearETag;
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:17,代码来源:EventualBlobStore.java

示例2: handleAbortMultipartUpload

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
private static void handleAbortMultipartUpload(HttpServletResponse response,
        BlobStore blobStore, String containerName, String blobName,
        String uploadId) throws IOException, S3Exception {
    if (Quirks.MULTIPART_REQUIRES_STUB.contains(getBlobStoreType(
            blobStore))) {
        if (!blobStore.blobExists(containerName, uploadId)) {
            throw new S3Exception(S3ErrorCode.NO_SUCH_UPLOAD);
        }

        blobStore.removeBlob(containerName, uploadId);
    }

    // TODO: how to reconstruct original mpu?
    MultipartUpload mpu = MultipartUpload.create(containerName,
            blobName, uploadId, createFakeBlobMetadata(blobStore),
            new PutOptions());
    blobStore.abortMultipartUpload(mpu);
    response.sendError(HttpServletResponse.SC_NO_CONTENT);
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:20,代码来源:S3ProxyHandler.java

示例3: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(String containerName, Blob blob,
        PutOptions options) {
    long length;
    try (InputStream is = blob.getPayload().openStream()) {
        length = ByteStreams.copy(is, ByteStreams.nullOutputStream());
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

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

    return super.putBlob(containerName, blob, options);
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:21,代码来源:NullBlobStore.java

示例4: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(String containerName, Blob blob, PutOptions options) {
    String blobName = blob.getMetadata().getName();
    if (blobName.startsWith(INTERNAL_PREFIX)) {
        throw new UnsupportedOperationException("illegal prefix");
    }
    if (BounceLink.isLink(blob.getMetadata())) {
        throw new IllegalArgumentException(blobName + " is a link");
    }

    try (ReconcileLocker.LockKey ignored = reconcileLocker.lockObject(containerName, blobName, false)) {
        putMarkerBlob(containerName, blobName);
        String etag = getSource().putBlob(containerName, blob, options);
        enqueueReconcile(containerName, blobName);
        return etag;
    }
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:18,代码来源:WriteBackPolicy.java

示例5: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(String containerName, Blob blob, PutOptions options) {
    BouncePolicy policy = getPolicyFromContainer(containerName);
    if (blob.getMetadata().getName().equals(lastPutObject)) {
        // drain bounce if this is an immediate overwrite, because
        // we could be bouncing this object
        drainBackgroundTasks();
    }
    Long length = blob.getMetadata().getContentMetadata().getContentLength();
    lastPutObject = blob.getMetadata().getName();
    String result = policy.putBlob(containerName, blob, options);
    if (result == null) {
        return null;
    }
    if (length != null) {
        pendingBytes.getAndAdd(length);
    }
    pendingObjects.getAndIncrement();
    return result;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:21,代码来源:AutoConfigBlobStore.java

示例6: multipartUploadExample

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
private static void multipartUploadExample(BlobStore blobstore) throws IOException {
   // Create a container
   String containerName = "jclouds_multipartUploadExample_" + UUID.randomUUID().toString();
   blobstore.createContainerInLocation(null, containerName); // Create a vault

   // Create a blob
   ByteSource payload = buildData(16 * MiB);
   Blob blob = blobstore.blobBuilder("ignored") // The blob name is ignored in Glacier
         .payload(payload)
         .contentLength(payload.size())
         .build();

   // Create the PutOptions
   PutOptions options = PutOptions.Builder.multipart(true);

   // Put the blob in the container
   blobstore.putBlob(containerName, blob, options);
   System.out.println("The blob has been uploaded");
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:20,代码来源:MainApp.java

示例7: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(String container, Blob blob, PutOptions options) {
    if (options != null && !options.isMultipart()) {
        throw new IllegalArgumentException("only multipart is supported by this provider");
    }
    Payload payload = checkNotNull(blob.getPayload());
    BlobMetadata metadata = blob.getMetadata();
    ContentMetadata contentMetadata = metadata.getContentMetadata();
    GridFS gridFS = parseGridFSIdentifier(container).connect(mongo);
    GridFSInputFile inputFile = gridFS.createFile(payload.getInput(), metadata.getName(), true);
    inputFile.setContentType(contentMetadata.getContentType());
    DBObject fileMetadata = new BasicDBObject();
    fileMetadata.putAll(metadata.getUserMetadata());
    inputFile.setMetaData(fileMetadata);
    inputFile.save();
    return inputFile.getMD5();
}
 
开发者ID:mhurne,项目名称:jclouds-gridfs-blobstore,代码行数:18,代码来源:GridFSBlobStore.java

示例8: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(String container, Blob blob, PutOptions options) {
   OSS oss = api.getOSSClient(OSSApi.DEFAULT_REGION);
   String region = oss.getBucketLocation(container);
   oss = api.getOSSClient(region);
   PutObjectResult result = null;
   try {
      result = oss.putObject(container, blob.getMetadata().getProviderId(), blob.getPayload().openStream());
   } catch (Exception e) {
      logger.warn(e.getMessage());
   }
   return result.getETag();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:14,代码来源:OSSBlobStore.java

示例9: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Test
public void putBlob() {
   byte[] bs = new byte[100 * 1024];
   for (int i = 0; i < 100 * 1024; i++) {
      bs[i] = 0;
   }
   Blob blob1 = blobStore.blobBuilder("putblob-1").payload(bs).build();
   blobStore.putBlob(testBucket, blob1);
   Blob blob2 = blobStore.blobBuilder("putblob-2").payload(bs).build();
   blobStore.putBlob(testBucket, blob2, PutOptions.NONE);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:12,代码来源:OSSTest.java

示例10: handleCreateMultipartUpload

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
private void handleCreateMultipartUpload(HttpExchange request, Map<String, String> params) throws IOException {
    String vault = params.get("vault");
    if (!proxy.getBlobStore().containerExists(vault)) {
        Util.sendNotFound("Vault", vault, request);
        return;
    }

    String partSizeHeader = request.getRequestHeaders().getFirst("x-amz-part-size");
    if (partSizeHeader == null) {
        Util.sendBadRequest("Missing part size header (x-amz-part-size)", request);
        return;
    }
    long partSize;
    try {
        partSize = Long.parseLong(partSizeHeader);
    } catch (NumberFormatException e) {
        Util.sendBadRequest("Invalid part size", request);
        return;
    }
    UUID archiveId = UUID.randomUUID();
    Blob mpuBlob = proxy.getBlobStore().blobBuilder(archiveId.toString()).build();
    MultipartUpload mpu = proxy.getBlobStore().initiateMultipartUpload(vault, mpuBlob.getMetadata(), new PutOptions());
    if (mpu == null) {
        Util.sendServerError("Failed to create an upload", request);
        return;
    }
    String description = request.getRequestHeaders().getFirst("x-amz-archive-description");
    Upload upload = new Upload(partSize, description, mpu);
    UUID uploadId = proxy.createMultipartUpload(vault, upload);
    request.getResponseHeaders().put("x-amz-multipart-upload-id", ImmutableList.of(uploadId.toString()));
    request.getResponseHeaders().put("Location", ImmutableList.of(
            Util.getMultipartLocation(params.get("account"), vault, uploadId.toString())));
    request.sendResponseHeaders(Response.Status.CREATED.getStatusCode(), -1);
}
 
开发者ID:bouncestorage,项目名称:glacier-proxy,代码行数:35,代码来源:Multipart.java

示例11: initiateMultipartUpload

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public MultipartUpload initiateMultipartUpload(String container,
        BlobMetadata blobMetadata, PutOptions options) {
    MultipartUpload mpu = delegate().initiateMultipartUpload(container,
            blobMetadata, options);
    return mpu;
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:8,代码来源:EventualBlobStore.java

示例12: testReadAfterMultipartUpload

import org.jclouds.blobstore.options.PutOptions; //导入依赖的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

示例13: testPutBlobOptions

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Test
public void testPutBlobOptions() throws Exception {
    try {
        readOnlyBlobStore.putBlob(containerName, null, new PutOptions());
        Fail.failBecauseExceptionWasNotThrown(
                UnsupportedOperationException.class);
    } catch (UnsupportedOperationException ne) {
        // expected
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:11,代码来源:ReadOnlyBlobStoreTest.java

示例14: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(String containerName, Blob blob, PutOptions options) {
    Date startTime = new Date();
    String result = delegate().putBlob(containerName, blob, options);
    app.getBounceStats().logOperation(HttpMethod.PUT, getProviderId(), containerName, blob.getMetadata().getName(),
            blob.getMetadata().getContentMetadata().getContentLength(), startTime.getTime());
    return result;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:9,代码来源:LoggingBlobStore.java

示例15: putBlob

import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(String containerName, Blob blob, PutOptions options) {
    String eTag = super.putBlob(containerName, blob, options);
    // the mtime of this object just got updated, we can fall back to that
    lru.remove(getLRUKey(containerName, blob.getMetadata().getName()));
    return eTag;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:8,代码来源:LRUStoragePolicy.java


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