本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例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");
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例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
}
}
示例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;
}
示例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;
}