azure-sdk-for-android/tools/storage-test-service
Brandon Siegel 867507cc2e Centralize .gitignores 2020-03-03 11:26:06 -08:00
..
gradle/wrapper Test service for sas generation (#152) 2020-01-08 18:06:02 -08:00
src/main/java/azandroid/storage Test service for sas generation (#152) 2020-01-08 18:06:02 -08:00
README.md Test service for sas generation (#152) 2020-01-08 18:06:02 -08:00
build.gradle Test service for sas generation (#152) 2020-01-08 18:06:02 -08:00
gradlew Test service for sas generation (#152) 2020-01-08 18:06:02 -08:00
gradlew.bat Test service for sas generation (#152) 2020-01-08 18:06:02 -08:00
manifest.yml Test service for sas generation (#152) 2020-01-08 18:06:02 -08:00

README.md

storage-test-service

A light weight locally executable REST service that can be used to generate Storage SaS token to test mobile TransferManager implementations.

Run the service locally:

  1. From terminal switch to storage-test-service directory
  2. Run gradle clean build to produce az-mobile-storage-service-0.1.0.jar under .\build\lib
  3. create settings.xml in the current directory (i.e. in storage-test-service)

settings.xml

<?xml version = "1.0" encoding = "UTF-8"?>

<beans xmlns = "http://www.springframework.org/schema/beans"
       xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation = "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <bean id = "settings" class = "azandroid.storage.applicationcontext.Settings">
        <property name = "connectionString"
                  value = "DefaultEndpointsProtocol=https;AccountName=<storage-account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net"/>
    </bean>
</beans>

Update value of connectionString::value attribute with storage connection string.

  1. Start the service
java  -jar build/libs/az-mobile-storage-service-0.1.0.jar

Consume service from mobile emulators:

From Android emulator, http://10.0.2.2:8080 can be used to reach the locally running service. To access from iOS emulator, use http://localhost:8080.

  1. To create a container in the storage account configured in settings.xml, send request like:
POST http://10.0.2.2:8080/create-container
Content-Type: application/json
{
	"containerName": "mobilecontainer"
}
  1. To generate a Sas token for a blob in the container, send request like:
POST http://10.0.2.2:8080/generate-sas
Content-Type: application/json
{
	"containerName": "mobilecontainer",
    "blobName":"image1.png"
    "accessDurationInMinutes": 60
}

service will return:

{
    "containerName": "mobilecontainer",
    "blobName": "image1.png",
    "sasToken": "<access-token>",
    "sasUri": "https://<account-name>.blob.core.windows.net/mobilecontainer/image1.png?<access-token>"
}