Skip to content

Instantly share code, notes, and snippets.

@qrtt1
Last active December 10, 2015 16:19
Show Gist options
  • Save qrtt1/4460281 to your computer and use it in GitHub Desktop.
Save qrtt1/4460281 to your computer and use it in GitHub Desktop.
azure java sdk lab
runtime - Classpath for running the compiled main classes.
+--- com.microsoft.windowsazure:microsoft-windowsazure-api:0.3.3
| +--- com.sun.jersey:jersey-client:1.10-b02
| +--- javax.inject:javax.inject:1
| +--- com.sun.jersey:jersey-json:1.10-b02
| | +--- org.codehaus.jettison:jettison:1.1
| | | \--- stax:stax-api:1.0.1
| | +--- com.sun.xml.bind:jaxb-impl:2.2.3-1
| | | \--- javax.xml.bind:jaxb-api:2.2.2
| | | +--- javax.xml.stream:stax-api:1.0-2
| | | \--- javax.activation:activation:1.1
| | +--- org.codehaus.jackson:jackson-core-asl:1.8.3
| | +--- org.codehaus.jackson:jackson-mapper-asl:1.8.3
| | | \--- org.codehaus.jackson:jackson-core-asl:1.8.3 (*)
| | +--- org.codehaus.jackson:jackson-jaxrs:1.8.3
| | | +--- org.codehaus.jackson:jackson-core-asl:1.8.3 (*)
| | | \--- org.codehaus.jackson:jackson-mapper-asl:1.8.3 (*)
| | \--- org.codehaus.jackson:jackson-xc:1.8.3
| | +--- org.codehaus.jackson:jackson-core-asl:1.8.3 (*)
| | \--- org.codehaus.jackson:jackson-mapper-asl:1.8.3 (*)
| +--- commons-logging:commons-logging:1.1.1
| +--- javax.mail:mail:1.4
| | \--- javax.activation:activation:1.1 (*)
| \--- org.apache.commons:commons-lang3:3.1
+--- commons-logging:commons-logging:1.1.1 (*)
+--- commons-lang:commons-lang:2.6
\--- commons-io:commons-io:2.4
//
// learning from http://www.windowsazure.com/en-us/develop/java/how-to-guides/blob-storage
//
package net.muzee.az;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.util.Properties;
import com.microsoft.windowsazure.services.blob.client.CloudBlobClient;
import com.microsoft.windowsazure.services.blob.client.CloudBlobContainer;
import com.microsoft.windowsazure.services.blob.client.CloudBlockBlob;
import com.microsoft.windowsazure.services.core.storage.CloudStorageAccount;
import com.microsoft.windowsazure.services.core.storage.StorageException;
public class Main {
public static void main(String[] args) throws InvalidKeyException, URISyntaxException, StorageException,
FileNotFoundException, IOException {
Properties properties = new Properties();
properties.load(Main.class.getResourceAsStream("/cfg.properties"));
// Retrieve storage account from connection-string
CloudStorageAccount storageAccount = CloudStorageAccount.parse(properties.getProperty("auth.info"));
// Create the blob client
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
// Get a reference to a container
// The container name must be lower case
CloudBlobContainer container = blobClient.getContainerReference("ttt");
long t1 = System.currentTimeMillis();
File source = new File("/Users/qrtt1/Downloads/MuzeeS3Deployer.zip");
CloudBlockBlob blob = container.getBlockBlobReference(source.getName());
blob.upload(new FileInputStream(source), source.length());
long t2 = System.currentTimeMillis();
System.out.println(t2 - t1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment