Skip to content

Commit

Permalink
Merge pull request Azure#151 from WindowsAzure/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
joostdenijs committed Sep 19, 2012
2 parents 812ae84 + 81d1251 commit fe11a2f
Showing 1 changed file with 52 additions and 55 deletions.
107 changes: 52 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ 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.

```xml
<dependency>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.3.0</version>
</dependency>
```
<dependency>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.3.1</version>
</dependency>

##Minimum Requirements

Expand All @@ -64,63 +62,62 @@ deployment tools.
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 com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.blob.client.*;

public class BlobSample {
import com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.blob.client.*;

public static final String storageConnectionString =
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;
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();
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);
}
// 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 fe11a2f

Please sign in to comment.