The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing

Insights

External Resources

More Info


Page tree
Skip to end of metadata
Go to start of metadata

When testing mobile applications, you have the option to temporarily store your app, for up to 60 days, on Application Storage. Below are some topics surrounding Application Storage.

What You'll Need

Upload an App with App-Upload

  1. Log in to Sauce Labs and select LIVE from the options in the left-hand navigation.
  2. Select Mobile-App.
  3. You will see a list of previously uploaded apps.
  4. To the right of the page, select App Upload to upload a new application (Note: Live Testing on Real Devices only at the moment):


You can either drag and drop and application, or browse for the file (*.APK or *.IPA format).


Upload an App with the REST API

Below are some examples of how to use the Sauce Labs REST API to upload your mobile application to Sauce Storage. If you do not have an app, consider using the Sauce Labs Swag Labs sample app for validating your account, as well as your tests' functionality .

REST API Authentication

The APIs and authorization credentials are located here: app.saucelabs.com

A recommended best practice is to set your credentials as environment variables like so:

SAUCE_USERNAME='valid.username'
SAUCE_ACCESS_KEY='valid.key'

For specific instructions on how to set environment variables visit, the following links:

Extended Team Management Sync

App Storage uses an XTM (Extended Team Management) sync feature which allows for user permissions schemes. In other words, a Sauce Labs admin (either an org admin or a team admin) can control access to individual application files or specific binary/script files. By default, all uploaded files are shared with the same team where the user participates currently. You, as a user, can only access files that are shared with the team where you contribute/participate unless your role is an organization admin in which case you have access to all files in your particular organization.

To manage access to your organization go to Account > Team Management

Storage API Endpoints

There are two main contexts/branches for the storage API:

  • one for working with separate application builds (individual builds, application files, etc.).
  • one for working with apps (groups of application builds with the same unique identifier, belonging to the same platform and team).

Upload

Mac OSX / Linux Example
$ curl -F "payload=@/Users/$SAUCE_USERNAME/Downloads/<file_name>.apk" -F name=<file_name>.apk -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY"  'https://api.us-west-1.saucelabs.com/v1/storage/upload'
Windows Example
> curl -F "payload=@\Users\%SAUCE_USERNAME%\Downloads\<file_name>.apk" -F name=<file_name>.apk -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%"  'https://api.us-west-1.saucelabs.com/v1/storage/upload'
Example Response (JSON)
{
   "item":{
      "id":"379c301a-199c-4b40-ad45-4a95e5f30a3a",
      "owner":{
         "id":"286c0fbb0cb644c4a012d505b8a0a1ac",
         "org_id":"c064890612424e34a12fca98ce4f32c6"
      },
      "name":"Android.SauceLabs.Mobile.Sample.app.2.3.0.apk",
      "upload_timestamp":1593450387,
      "etag":"0cf189b1c4c17a56656ada5e2d75cd51",
      "kind":"android",
      "group_id":2807,
      "metadata":{
         "identifier":"com.swaglabsmobileapp",
         "name":"Swag Labs Mobile App",
         "version":"2.3.0",
         "icon":"<long-serial-number>",
         "version_code":13,
         "min_sdk":16,
         "target_sdk":28
      },
      "access":{
         "team_ids":[
            "a15e40997f2b44ee9615d9803cb4b439"
         ],
         "org_ids":[

         ]
      }
   }
}
Mac OSX / Linux Example
$ curl -F "payload=@/Users/$SAUCE_USERNAME/Downloads/$FILE_NAME.ipa" -F "name=$FILE_NAME.ipa" -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY"  'https://api.eu-central-1.saucelabs.com/v1/storage/upload'
Windows Example
> curl -F "payload=@\Users\%SAUCE_USERNAME%\Downloads\%FILE_NAME%.ipa" -F "name=%FILE_NAME%.ipa" -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%"  'https://api.eu-central-1.saucelabs.com/v1/storage/upload'
Example Response (JSON)
{
   "item":{
      "id":"379c301a-199c-4b40-ad45-4a95e5f30a3a",
      "owner":{
         "id":"286c0fbb0cb644c4a012d505b8a0a1ac",
         "org_id":"c064890612424e34a12fca98ce4f32c6"
      },
      "name":"Android.SauceLabs.Mobile.Sample.app.2.3.0.apk",
      "upload_timestamp":1593450387,
      "etag":"0cf189b1c4c17a56656ada5e2d75cd51",
      "kind":"android",
      "group_id":2807,
      "metadata":{
         "identifier":"com.swaglabsmobileapp",
         "name":"Swag Labs Mobile App",
         "version":"2.3.0",
         "icon":"<long-serial-number>",
         "version_code":13,
         "min_sdk":16,
         "target_sdk":28
      },
      "access":{
         "team_ids":[
            "a15e40997f2b44ee9615d9803cb4b439"
         ],
         "org_ids":[

         ]
      }
   }
}

Download

Note: Each instance of an uploaded application generates a unique identification number. If you're not sure of the file_id number you can use the files management endpoints to find the desired key.

Mac OSX / Linux Example
$ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.us-west-1.saucelabs.com/v1/storage/download/<file_id>' -o /path/to/test/code/app-name
Windows Example
> curl -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.us-west-1.saucelabs.com/v1/storage/download/<file_id>' -o \path\to\test\code\app-name
Mac OSX / Linux Example
$ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.eu-central-1.saucelabs.com/v1/storage/download/<file_id>' -o /path/to/test/code
Windows Example
> curl -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.eu-central-1.saucelabs.com/v1/storage/download/<file_id>' -o \path\to\test\code

Files

Possible Parameters for /files:

  • q: search term (semantic version, build number, file name, app name, app identifier, etc.)
  • kind = ios, android, other
  • file_id = one or more file ids to be listed
  • team_id = one or more team ids the listed file(s) should be shared with
  • page = the number of the current page to show, by default it starts from one
  • per_page = the count of items per listed page. By default it is 25, and the acceptable range is 1-100
Mac OSX / Linux Example
$ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.us-west-1.saucelabs.com/v1/storage/files/<file_id>?q=2&kind=android'
Windows Example
> curl -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.us-west-1.saucelabs.com/v1/storage/files/<file_id>?q=2&kind=android'
Example Response (JSON)
{
   "items":[
      {
         "id":"379c301a-199c-4b40-ad45-4a95e5f30a3a",
         "owner":{
            "id":"286c0fbb0cb644c4a012d505b8a0a1ac",
            "org_id":"c064890612424e34a12fca98ce4f32c6"
         },
         "name":"Android.SauceLabs.Mobile.Sample.app.2.3.0.apk",
         "upload_timestamp":1593450387,
         "etag":"0cf189b1c4c17a56656ada5e2d75cd51",
         "kind":"android",
         "group_id":2807,
         "metadata":{
            "identifier":"com.swaglabsmobileapp",
            "name":"Swag Labs Mobile App",
            "version":"2.3.0",
            "icon":"<long-serial-number",
            "version_code":13,
            "min_sdk":16,
            "target_sdk":28
         },
         "access":{
            "team_ids":[
               "a15e40997f2b44ee9615d9803cb4b439"
            ],
            "org_ids":[

            ]
         }
      }
   ],
   "links":{
      "prev":null,
      "next":null,
      "self":"?379c301a-199c-4b40-ad45-4a95e5f30a3a=&page=1&per_page=25"
   },
   "page":1,
   "per_page":25,
   "total_items":1
}
Mac OSX / Linux Example
$ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.eu-central-1.saucelabs.com/v1/storage/files?<file_id>&q=2&kind=android'
Windows Example
> curl -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.eu-central-1.saucelabs.com/v1/storage/files?<file_id>&q=2&kind=android'
Example Response (JSON)
{
   "items":[
      {
         "id":"379c301a-199c-4b40-ad45-4a95e5f30a3a",
         "owner":{
            "id":"286c0fbb0cb644c4a012d505b8a0a1ac",
            "org_id":"c064890612424e34a12fca98ce4f32c6"
         },
         "name":"Android.SauceLabs.Mobile.Sample.app.2.3.0.apk",
         "upload_timestamp":1593450387,
         "etag":"0cf189b1c4c17a56656ada5e2d75cd51",
         "kind":"android",
         "group_id":2807,
         "metadata":{
            "identifier":"com.swaglabsmobileapp",
            "name":"Swag Labs Mobile App",
            "version":"2.3.0",
            "icon":"<long-serial-number",
            "version_code":13,
            "min_sdk":16,
            "target_sdk":28
         },
         "access":{
            "team_ids":[
               "a15e40997f2b44ee9615d9803cb4b439"
            ],
            "org_ids":[

            ]
         }
      }
   ],
   "links":{
      "prev":null,
      "next":null,
      "self":"?379c301a-199c-4b40-ad45-4a95e5f30a3a=&page=1&per_page=25"
   },
   "page":1,
   "per_page":25,
   "total_items":1
}

Groups (App)

Possible Parameters for /groups:

  • q: search term (semantic version, build number, file name, app name, app identifier, etc.)
  • kind = ios, android, other
  • group_id = one or more group ids to be listed
  • page = the number of the current page to show, by default it starts from one
  • per_page = the count of items per listed page. By default it is 25, and the acceptable range is 1-100


Mac OSX / Linux Example
$ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.us-west-1.saucelabs.com/v1/storage/groups?<group_id>&q=2&kind=android'
Windows Example
> curl -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.us-west-1.saucelabs.com/v1/storage/groups?<group_id>&q=2&kind=android'
Mac OSX / Linux Example
$ curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.eu-central-1.saucelabs.com/v1/storage/groups/<group_id>?q=2&kind=android'
Windows Example
> curl -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.eu-central-1.saucelabs.com/v1/storage/groups/<group_id>?q=2&kind=android'
Example Response (JSON)
{
   "items":[
      {
         "id":2807,
         "name":"com.swaglabsmobileapp",
         "recent":{
            "id":"379c301a-199c-4b40-ad45-4a95e5f30a3a",
            "owner":{
               "id":"286c0fbb0cb644c4a012d505b8a0a1ac",
               "org_id":"c064890612424e34a12fca98ce4f32c6"
            },
            "name":"Android.SauceLabs.Mobile.Sample.app.2.3.0.apk",
            "upload_timestamp":1593450387,
            "etag":"0cf189b1c4c17a56656ada5e2d75cd51",
            "kind":"android",
            "group_id":2807,
            "metadata":{
               "identifier":"com.swaglabsmobileapp",
               "name":"Swag Labs Mobile App",
               "version":"2.3.0",
               "icon":"<long-serial-number>",
               "version_code":13,
               "min_sdk":16,
               "target_sdk":28
            },
            "access":{
               "team_ids":[
                  "a15e40997f2b44ee9615d9803cb4b439"
               ],
               "org_ids":[

               ]
            }
         },
         "count":1,
         "access":{
            "team_ids":[
               "a15e40997f2b44ee9615d9803cb4b439"
            ],
            "org_ids":[

            ]
         },
         "settings":{
            "proxy":{
               "host":"",
               "port":0
            },
            "proxy_enabled":false,
            "lang":"en_GB",
            "orientation":null,
            "instrumentation_enabled":true,
            "instrumentation":{
               "image_injection":true
            }
         }
      }
   ],
   "links":{
      "prev":null,
      "next":null,
      "self":"?2807=&page=1&per_page=25"
   },
   "page":1,
   "per_page":25,
   "total_items":1
}


Delete

Generally there are two ways to delete existing applications in App Storage API:

  • Delete a group of files by group_id (for example application builds with the same identifier)
  • Delete a single file/application build by file_id

Mac OSX / Linux Example
// Delete a Single File
$ curl -X DELETE -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.us-west-1.saucelabs.com/v1/storage/<file_id>'


// Delete a Group of Files
$ curl -X DELETE -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.us-west-1.saucelabs.com/v1/storage/groups/<group_id>'
Windows Example
// Delete a Single File
> curl -X DELETE -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.us-west-1.saucelabs.com/v1/storage/<file_id>'

// Delete a Group of Files
> curl -X DELETE -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.us-west-1.saucelabs.com/v1/storage/groups/<group_id>'
Mac OSX / Linux Example
// Delete a Single File
$ curl -X DELETE -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.eu-central-1.saucelabs.com/v1/storage/<file_id>'


// Delete a Group of Files
$ curl -X DELETE -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" 'https://api.eu-central-1.saucelabs.com/v1/storage/groups/<group_id>'
Windows Example
// Delete a Single File
> curl -X DELETE -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.eu-central-1.saucelabs.com/v1/storage/<file_id>'

// Delete a Group of Files
> curl -X DELETE -u "%SAUCE_USERNAME%:%SAUCE_ACCESS_KEY%" 'https://api.eu-central-1.saucelabs.com/v1/storage/groups/<group_id>'




  • No labels