Skip to content

Commit

Permalink
Merge pull request #9 from emgerner-msft/master
Browse files Browse the repository at this point in the history
Android Storage Client Library 0.4.1
  • Loading branch information
emgerner-msft committed Jan 6, 2015
2 parents e6bd45f + 4043ff5 commit 7dfbe74
Show file tree
Hide file tree
Showing 40 changed files with 927 additions and 666 deletions.
11 changes: 7 additions & 4 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
2014.12.22 Version 0.4.0
2015.01 Version 0.4.1
* Fixed a bug for Android 5.0 only that caused auth failures on deletes.

2014.12 Version 0.4.0
* Deprecated getSubDirectoryReference() for blob directories and file directories. Use getDirectoryReference() instead.
* Fixed a bug where maxResults was not verified to be positive for list operations.
* Deprecated AuthenticationScheme and its getter and setter. In the future only SharedKey will be used.
* Added support for EndpointSuffix which was previously not accepted in Account Strings.
* Fixed a bug where high precision Date values stored on Table Entites were forced to fit into milliseconds resulting in inaccuracies. Precision is limited to 1 millisecond by the Android Date class. If greater precision is required, the String should be used directly.
* Added TableRequestOptions.dateBackwardCompatibility, which supports reading Date values on Table Entities written using versions of this library prior to 0.4.0. See http://go.microsoft.com/fwlink/?LinkId=523753 for more details.

2014.10.10 Version 0.3.1
2014.10 Version 0.3.1
* Fixed a bug where a NullPointerException was thrown instead of a NetworkOnMainThreadException if code was executed on the main thread.

2014.08.01 Version 0.3.0
2014.08 Version 0.3.0
* Added the NameValidator class which contains helpers that check to see if resource names are valid.
* Fixed a bug where the RequestUrl of a LogRecord was not correctly HTML4 decoded.
* Made FileRange class and ListFilesAndDirectories method in the CloudFileDirectory class public.

2014.07.02 Version 0.2.0
2014.07 Version 0.2.0
* Added File Service support. The File Service and the associated SDK APIs are in preview.
* Added CloudAnalyticsClient and related methods to simplify Storage Analytics logging and metrics use case scenarios.
* Fixed a bug where an empty file would be left over during the downloadToFile error case.
Expand Down
64 changes: 5 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ First, add mavenCentral to your repositories by adding the following to your gra
Then, add a dependency by adding the following to your gradle build file:

dependencies {
compile 'com.microsoft.azure.android:azure-storage-android:0.3.0@aar'
compile 'com.microsoft.azure.android:azure-storage-android:0.4.1@aar'
}

###Option 4: aar via Maven
Expand All @@ -55,7 +55,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
<dependency>
<groupId>com.microsoft.azure.android</groupId>
<artifactId>azure-storage-android</artifactId>
<version>0.3.1</version>
<version>0.4.1</version>
<type>aar</type>
</dependency>
```
Expand All @@ -77,63 +77,9 @@ Make sure the storage client library is added as a project dependency. If using

If using Maven or Gradle, Jackson-Core should be automatically added to the build path. Otherwise, please download the jar and add it to your build path. Also, please make sure that the jar will be added to your project's apk. To do this in Eclipse, right click your project, select "Build Path->Configure Build Path", navigate to the "Order and Export" tab and check the box next to the jackson-core jar.

##Code Sample

The following is a quick example on how to upload a file to azure blob and download it back. You may also download and view the samples in the microsoft-azure-storage-samples folder. For additional information on using the Android client library, the Java [general documentation](http://azure.microsoft.com/en-us/develop/java/) and Java How To guides for [blobs](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-blob-storage/), [queues](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-queue-storage/), [tables](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-table-storage/) may be helpful.

```java
import java.io.*;

import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.blob.*;

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 = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient serviceClient = account.createCloudBlobClient();

// Container name must be lower case.
CloudBlobContainer container = serviceClient.getContainerReference("myimages");
container.createIfNotExists();

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

// Upload an image file.
CloudBlockBlob blob = container.getBlockBlobReference("image1.jpg");
File sourceFile = new File("c:\\myimages\\image1.jpg");
blob.upload(new FileInputStream(sourceFile), sourceFile.length());

// Download the image file.
File destinationFile = new File(sourceFile.getParentFile(), "image1Download.tmp");
blob.downloadToFile(destinationFile.getAbsolutePath());
}
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);
}
}
}
```
##Code Samples

Runnable samples for blob, queue, and table may be found in the microsoft-azure-storage-samples directory. To run these samples, specify a connection string in the MainActivity class and add a dependency on the Android client library. For additional information on using the Android client library, the Java [general documentation](http://azure.microsoft.com/en-us/develop/java/) and Java How To guides for [blobs](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-blob-storage/), [queues](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-queue-storage/), [tables](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-table-storage/) may be helpful.

#Need Help?

Expand Down
21 changes: 18 additions & 3 deletions microsoft-azure-storage-samples/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microsoft.azure.android.sample"
package="com.microsoft.azure.storage.samples"
android:versionCode="0"
android:versionName="0.4.0" >
android:versionName="0.4.1" >

<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />
android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.microsoft.azure.storage.samples.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions microsoft-azure-storage-samples/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.microsoft.azure.storage.samples.MainActivity"
tools:ignore="MergeRootFrame" />

70 changes: 70 additions & 0 deletions microsoft-azure-storage-samples/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.microsoft.azure.storage.samples.MainActivity$PlaceholderFragment" >

<Button
android:id="@+id/runBlobGettingStartedSampleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:onClick="runBlobGettingStartedSample"
android:text="@string/blob_getting_started_button" />

<Button
android:id="@+id/runQueueGettingStartedSampleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/runBlobGettingStartedSampleButton"
android:layout_marginTop="16dp"
android:onClick="runQueueGettingStartedSample"
android:text="@string/queue_getting_started_button" />

<Button
android:id="@+id/runTableGettingStartedSampleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/runQueueGettingStartedSampleButton"
android:layout_marginTop="16dp"
android:onClick="runTableGettingStartedSample"
android:text="@string/table_getting_started_button" />

<Button
android:id="@+id/runTablePayloadFormatSampleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/runTableGettingStartedSampleButton"
android:layout_marginTop="16dp"
android:onClick="runTablePayloadFormatSample"
android:text="@string/table_payload_format_button" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/runTablePayloadFormatSampleButton"
android:layout_marginTop="16dp"
android:ems="10" />
</RelativeLayout>

</ScrollView>
11 changes: 11 additions & 0 deletions microsoft-azure-storage-samples/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.microsoft.azure.storage.samples.MainActivity" >

<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>

</menu>
11 changes: 11 additions & 0 deletions microsoft-azure-storage-samples/res/values-v11/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<resources>

<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>

</resources>
12 changes: 12 additions & 0 deletions microsoft-azure-storage-samples/res/values-v14/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<resources>

<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>

</resources>
10 changes: 10 additions & 0 deletions microsoft-azure-storage-samples/res/values-w820dp/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<resources>

<!--
Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
-->
<dimen name="activity_horizontal_margin">64dp</dimen>

</resources>
7 changes: 7 additions & 0 deletions microsoft-azure-storage-samples/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<resources>

<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>

</resources>
11 changes: 11 additions & 0 deletions microsoft-azure-storage-samples/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Azure Storage Samples</string>
<string name="blob_getting_started_button">Blob Getting Started Sample</string>
<string name="queue_getting_started_button">Queue Getting Started Sample</string>
<string name="table_getting_started_button">Table Getting Started Sample</string>
<string name="table_payload_format_button">Table Payload Format Sample</string>
<string name="action_settings">Settings</string>

</resources>
20 changes: 20 additions & 0 deletions microsoft-azure-storage-samples/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>
Loading

0 comments on commit 7dfbe74

Please sign in to comment.