use of org.jclouds.blobstore.domain.Blob in project jackrabbit-oak by apache.
the class CloudBlobStore method storeBlock.
/**
* Uploads the block to the cloud service.
*/
@Override
protected void storeBlock(byte[] digest, int level, byte[] data) throws IOException {
Preconditions.checkNotNull(context);
String id = StringUtils.convertBytesToHex(digest);
cache.put(id, data);
org.jclouds.blobstore.BlobStore blobStore = context.getBlobStore();
if (!blobStore.blobExists(cloudContainer, id)) {
Map<String, String> metadata = Maps.newHashMap();
metadata.put("level", String.valueOf(level));
Blob blob = blobStore.blobBuilder(id).payload(data).userMetadata(metadata).build();
String etag = blobStore.putBlob(cloudContainer, blob, multipart());
LOG.debug("Blob " + id + " created with cloud tag : " + etag);
} else {
LOG.debug("Blob " + id + " already exists");
}
}
use of org.jclouds.blobstore.domain.Blob in project dhis2-core by dhis2.
the class JCloudsFileResourceContentStore method saveFileResourceContent.
@Override
public String saveFileResourceContent(FileResource fileResource, byte[] bytes) {
Blob blob = createBlob(fileResource, bytes);
if (blob == null) {
return null;
}
putBlob(blob);
log.debug(String.format("File resource saved with key: %s", fileResource.getStorageKey()));
return fileResource.getStorageKey();
}
use of org.jclouds.blobstore.domain.Blob in project camel by apache.
the class JcloudsBlobStoreHelper method writeBlob.
/**
* Writes {@link Payload} to the the {@link BlobStore}.
*/
public static void writeBlob(BlobStore blobStore, String container, String blobName, Payload payload) {
if (blobName != null && payload != null) {
mkDirs(blobStore, container, blobName);
Blob blob = blobStore.blobBuilder(blobName).payload(payload).contentType(MediaType.APPLICATION_OCTET_STREAM).contentDisposition(blobName).build();
blobStore.putBlob(container, blob, multipart());
}
}
use of org.jclouds.blobstore.domain.Blob in project legacy-jclouds-examples by jclouds.
the class UploadLargeObject method uploadLargeObjectFromFile.
/**
* Upload a large object from a File using the Swift API.
* @throws ExecutionException
* @throws InterruptedException
*/
private void uploadLargeObjectFromFile(File largeFile) throws InterruptedException, ExecutionException {
System.out.println("Upload Large Object From File");
Blob blob = storage.blobBuilder(largeFile.getName()).payload(largeFile).build();
String eTag = storage.putBlob(Constants.CONTAINER, blob, multipart());
System.out.println(" Uploaded " + largeFile.getName() + " eTag=" + eTag);
}
use of org.jclouds.blobstore.domain.Blob in project legacy-jclouds-examples by jclouds.
the class UploadObjects method uploadObjectFromStringWithMetadata.
/**
* Upload an object from a String with metadata using the BlobStore API.
*/
private void uploadObjectFromStringWithMetadata() {
System.out.println("Upload Object From String With Metadata");
String filename = "uploadObjectFromStringWithMetadata.txt";
Map<String, String> userMetadata = new HashMap<String, String>();
userMetadata.put("key1", "value1");
Blob blob = storage.blobBuilder(filename).payload("uploadObjectFromStringWithMetadata").userMetadata(userMetadata).build();
storage.putBlob(Constants.CONTAINER, blob);
System.out.println(" " + filename);
}
Aggregations