azureblob
org.apache.jclouds.provider/azureblob
using jclouds Installation.{% highlight java %} import org.jclouds.blobstore.; import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.; import org.jclouds.azureblob.; import com.google.common.io.; import java.io.*;
String storageAccountName = “”; String storageAccountKey = “”; String containerName = “”; String blobFullyQualifiedFileName = “”; String blobName = “”;
// Get a context with amazon that offers the portable BlobStore api BlobStoreContext context = ContextBuilder.newBuilder(“azureblob”) .credentials(storageAccountName, storageAccountKey) .buildView(BlobStoreContext.class);
// Access the BlobStore BlobStore blobStore = context.getBlobStore();
// Create a Container blobStore.createContainerInLocation(null, containerName);
// Create a blob. ByteSource payload = Files.asByteSource(new File(blobFullyQualifiedFileName)); Blob blob = context.getBlobStore().blobBuilder(blobName) .payload(payload) // or InputStream .contentLength(payload.size()) .build();
// Upload the Blob blobStore.putBlob(containerName, blob);
// When you need access to azureblob-specific features, use the provider-specific context AzureBlobClient azureBlobClient = context.unwrapApi(AzureBlobClient.class); Object object = azureBlobClient.getBlobProperties(containerName, blobName);
System.out.println("Object: " + object); context.close(); {% endhighlight %}