本文整理汇总了Java中org.jclouds.blobstore.options.PutOptions类的典型用法代码示例。如果您正苦于以下问题:Java PutOptions类的具体用法?Java PutOptions怎么用?Java PutOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PutOptions类属于org.jclouds.blobstore.options包,在下文中一共展示了PutOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: putBlob
import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
@Override
public String putBlob(String container, Blob blob, PutOptions options) {
try (InputStream in = blob.getPayload().openStream()) {
ByteStreams.copy(in, ByteStreams.nullOutputStream());
} catch (IOException e) {
throw propagate(e);
}
return "";
}
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:10,代码来源:NullBlobStore.java
示例17: copySwiftBlob
import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
private static void copySwiftBlob(BlobStore from, BlobStore to, String containerNameTo, Blob blob) {
// TODO: swift object semantic changes if we do multipart upload,
// if both sides are swift, we may want to just copy the individual parts
PutOptions options = PutOptions.NONE;
if (blob.getMetadata().getContentMetadata().getContentLength() > to.getMaximumMultipartPartSize()) {
options = MULTIPART_PUT;
}
to.putBlob(containerNameTo, blob, options);
}
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:10,代码来源:Utils.java
示例18: copyBlob
import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
public static Blob copyBlob(BlobStore from, BlobStore to, String containerNameTo, Blob blobFrom,
boolean saveSystemMetadata)
throws IOException {
if (blobFrom == null) {
return null;
}
if (BounceLink.isLink(blobFrom.getMetadata())) {
throw new IllegalArgumentException(blobFrom.getMetadata().getName() + " is a link");
}
Map<String, String> userMetadata = blobFrom.getMetadata().getUserMetadata();
if (saveSystemMetadata) {
SystemMetadataSerializer.SYSTEM_METADATA
.forEach(t -> userMetadata.put(t.getName(), t.serialize(blobFrom.getMetadata())));
}
ContentMetadata metadata = blobFrom.getMetadata().getContentMetadata();
PayloadBlobBuilder builder = to.blobBuilder(blobFrom.getMetadata().getName())
.userMetadata(userMetadata)
.payload(new BlobStoreByteSource(from, blobFrom, blobFrom.getMetadata().getSize()));
copyToBlobBuilder(metadata, builder);
if (isSwiftBlobStore(to)) {
copySwiftBlob(from, to, containerNameTo, builder.build());
} else {
PutOptions options = PutOptions.NONE;
if (blobFrom.getMetadata().getSize() >= to.getMinimumMultipartPartSize()) {
options = MULTIPART_PUT;
}
to.putBlob(containerNameTo, builder.build(), options);
}
return blobFrom;
}
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:36,代码来源:Utils.java
示例19: putLargeObject
import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
private void putLargeObject(String blobName, long size) throws Exception {
/* running 5GB through transient blob store is asking for trouble */
skipIfTransient(policy);
Blob blob = policy.blobBuilder(blobName)
.payload(new ByteSourcePayload(new ByteSource() {
/* ByteSource by default keeps reading the stream to figure out the size */
@Override
public long size() throws IOException {
return size;
}
@Override
public InputStream openStream() throws IOException {
return new BoundedInputStream(new ZeroInputStream(), size);
}
}))
.contentLength(size)
.build();
logger.info("putting large object {}", blobName);
policy.putBlob(containerName, blob, new PutOptions().multipart());
logger.info("done putting large object {}", blobName);
assertThat(policy.getDestination().blobExists(containerName, blobName)).isFalse();
assertThat(policy.getSource().blobExists(containerName, blobName)).isTrue();
BlobMetadata nearBlob = policy.getSource().blobMetadata(containerName, blobName);
assertThat(nearBlob.getContentMetadata().getContentLength()).isEqualTo(size);
}
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:29,代码来源:WriteBackPolicyTest.java
示例20: PutOptionFileAttribute
import org.jclouds.blobstore.options.PutOptions; //导入依赖的package包/类
public PutOptionFileAttribute(PutOptions putOptions) {
this.putOptions = putOptions;
}
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:4,代码来源:PutOptionFileAttribute.java
注:本文中的org.jclouds.blobstore.options.PutOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论