Skip to content

Commit

Permalink
Merge pull request Azure#378 from WindowsAzure/release
Browse files Browse the repository at this point in the history
pull request from release branch to master branch
  • Loading branch information
xuezhai committed Jul 2, 2013
2 parents 55f7055 + 90362e0 commit 1309f14
Showing 1 changed file with 59 additions and 60 deletions.
119 changes: 59 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ This project provides a client library in Java that makes it easy to consume Win
* Create/Read/Update/Delete queues
* Send/Receive/Unlock/Delete messages
* Renew message lock
* Message forwarding
* Topics
* Create/Read/Update/Delete topics
* Create/Read/Update/Delete subscriptions
* Create/Read/Update/Delete rules
* Send/Receive/Unlock/Delete messages
* Renew message lock
* Message forwarding
* Media Services
* Create/Read/Update/Delete access policies
* Create/Read/Update/Delete asset files
Expand All @@ -53,11 +55,13 @@ To get the source code of the SDK via git just type:
To get the binaries of this library as distributed by Microsoft, ready for use
within your project you can also have them installed by the Java package manager Maven.

<dependency>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.4.3</version>
</dependency>
```xml
<dependency>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.4.4</version>
</dependency>
```

##Minimum Requirements

Expand All @@ -72,67 +76,62 @@ account. To host your Java code in Windows Azure, you additionally need to down
the full Windows Azure SDK for Java - which includes packaging, emulation, and
deployment tools.

##Code Samples
##Code Sample

The following is a quick example on how to set up a Azure blob using the API
and uploading a file to it. For additional information on using the client libraries to access Azure services see the How To guides listed [here](http://www.windowsazure.com/en-us/develop/java/).

```java
import java.io.*;

import com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.blob.client.*;

public class BlobSample {
public static final String storageConnectionString =
"DefaultEndpointsProtocol=http;"
+ "AccountName=your_account_name;"
+ "AccountKey= your_account_key";

public static void main(String[] args) {
try {
CloudStorageAccount account;
CloudBlobClient serviceClient;
CloudBlobContainer container;
CloudBlockBlob blob;

account = CloudStorageAccount.parse(storageConnectionString);
serviceClient = account.createCloudBlobClient();
// Container name must be lower case.
container = serviceClient.getContainerReference("blobsample");
container.createIfNotExist();

// Set anonymous access on the container.
BlobContainerPermissions containerPermissions;
containerPermissions = new BlobContainerPermissions();
container.uploadPermissions(containerPermissions);

// Upload an image file.
blob = container.getBlockBlobReference("image1.jpg");
File fileReference = new File("c:\\myimages\\image1.jpg");
blob.upload(new FileInputStream(fileReference), fileReference.length());
} catch (FileNotFoundException fileNotFoundException) {
System.out.print("FileNotFoundException encountered: ");
System.out.println(fileNotFoundException.getMessage());
System.exit(-1);
} catch (StorageException storageException) {
System.out.print("StorageException encountered: ");
System.out.println(storageException.getMessage());
System.exit(-1);
} catch (Exception e) {
System.out.print("Exception encountered: ");
System.out.println(e.getMessage());
System.exit(-1);
}

import com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.blob.client.*;

public class BlobSample {
public static final String storageConnectionString =
"DefaultEndpointsProtocol=http;" +
"AccountName=your_account_name;" +
"AccountKey= your_account_name";

public static void main(String[] args)
{
try
{
CloudStorageAccount account;
CloudBlobClient serviceClient;
CloudBlobContainer container;
CloudBlockBlob blob;
account = CloudStorageAccount.parse(storageConnectionString);
serviceClient = account.createCloudBlobClient();
// Container name must be lower case.
container = serviceClient.getContainerReference("blobsample");
container.createIfNotExist();
// Set anonymous access on the container.
BlobContainerPermissions containerPermissions;
containerPermissions = new BlobContainerPermissions();

// Upload an image file.
blob = container.getBlockBlobReference("image1.jpg");
File fileReference = new File ("c:\\myimages\\image1.jpg");
blob.upload(new FileInputStream(fileReference), fileReference.length());
}
catch (FileNotFoundException fileNotFoundException)
{
System.out.print("FileNotFoundException encountered: ");
System.out.println(fileNotFoundException.getMessage());
System.exit(-1);
}
catch (StorageException storageException)
{
System.out.print("StorageException encountered: ");
System.out.println(storageException.getMessage());
System.exit(-1);
}
catch (Exception e)
{
System.out.print("Exception encountered: ");
System.out.println(e.getMessage());
System.exit(-1);
}

}
}

}
```

#Need Help?

Expand Down

0 comments on commit 1309f14

Please sign in to comment.