Search in sources :

Example 6 with Blob

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");
    }
}
Also used : Blob(org.jclouds.blobstore.domain.Blob)

Example 7 with Blob

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();
}
Also used : Blob(org.jclouds.blobstore.domain.Blob)

Example 8 with Blob

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());
    }
}
Also used : Blob(org.jclouds.blobstore.domain.Blob)

Example 9 with Blob

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);
}
Also used : Blob(org.jclouds.blobstore.domain.Blob)

Example 10 with Blob

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);
}
Also used : Blob(org.jclouds.blobstore.domain.Blob) HashMap(java.util.HashMap)

Aggregations

Blob (org.jclouds.blobstore.domain.Blob)15 IOException (java.io.IOException)6 BlobStore (org.jclouds.blobstore.BlobStore)4 BlobStoreContext (org.jclouds.blobstore.BlobStoreContext)3 BlobStoreContextFactory (org.jclouds.blobstore.BlobStoreContextFactory)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 Properties (java.util.Properties)2 Payload (org.jclouds.io.Payload)2 EntityNotFoundException (org.qi4j.spi.entitystore.EntityNotFoundException)2 ByteSource (com.google.common.io.ByteSource)1 File (java.io.File)1 ObjectOutputStream (java.io.ObjectOutputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 HashMap (java.util.HashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 NullInputStream (org.apache.commons.io.input.NullInputStream)1 Configuration (org.apache.hadoop.conf.Configuration)1