AWS Mobile
Developer Guide

Hosting and Streaming

Choose AWS Mobile Hub Hosting and Streaming to:

  • Host content for you mobile web, native mobile or hybrid app

  • Distribute your content through a global Content Delivery Network (CDN)

  • Stream your media

Create a free Mobile Hub project with Hosting and Streaming. Get a custom sample app and SDK.

Feature Details

The Hosting and Streaming feature delivers content through a global network of endpoints using Amazon Simple Storage Service (Amazon S3) and Amazon CloudFront.

The following image shows how website assets and streaming media are distributed to a mobile web app or browser. The web app is shown requesting AWS credentials and accessing AWS services through the AWS SDK for JavaScript.

The following image shows a native or hybrid mobile app requesting AWS credentials to access content from a CDN edge location.

The Hosting and Streaming feature enables you to host website and app assets in the cloud, such as HTML, JavaScript, image, or media files. Mobile Hub creates a content source storage location (origin) using an Amazon S3 bucket. The bucket is made accessible to the internet through the Amazon S3 ability to statically host web content with no web server.

Low latency access to your content is provided to users in all regions by caching your source content on a global network of edge locations. This Content Distribution network (CDN) is provided through an Amazon CloudFront distribution which also supports media file streaming (see Amazon CloudFront streaming).

Hosting and Streaming At a Glance

AWS services and resources configured

Mobile Hub-enabled features use Amazon Cognito for authentication and IAM for authorization. For more information, see User Sign-in.

For more information, see Viewing AWS Resources Provisioned for this Feature.

Configuration options

This feature enables the following mobile backend capabilities:

  • Web app content hosting (Internet access for your content, no web servers required)

  • AWS SDK for JavaScript (Call AWS services via standard scripting)

  • Global CDN (Global content distribution and media streaming) CloudFront offers several options for regional scope and cost of your distribution. For more information, see Configuring the Hosting and Streaming Feature.

Web app demo

Sample

  • The AWS SDK for Javascript and a custom-generated configuration file are provisioned to your bucket.

For more information, see Web App Support.

Quickstart native app demos

This feature adds the following to a quickstart app generated by Mobile Hub:

  • View file list in AWS storage, download and view files, and manage their local cache.

Web App Support

When you enable Hosting and Streaming, Mobile Hub provisions a local copy of the AWS SDK for JavaScript in the root of your bucket.

Mobile Hub also generates the project configuration files aws-config.js and aws-exports.js, which contain endpoint constants for each AWS services Mobile Hub configured for your project. aws-exports.js is provided for integration with ES6 compatible scripting languages like Node.js. Use these values to make SDK calls to your services from your hosted web app.

Note

Best security practice is to reduce access to an app's resources as much as possible. These configuration files are publically accessible and contain identifiers for all of your app's AWS resources. If it suits your design, we recommend you protect your resources by allowing only authenticated users to access them. You can do this in this project by enabling the Mobile Hub User Sign-in with the Require sign-in option.

You can also copy the appropriate configuration file into your hybrid native/web mobile app to enable calling your AWS services from your app using JavaScript.

Configuring the Hosting and Streaming Feature

Browsing Your Content

With Hosting and Streaming enabled, you have several options:

  • Launch from Amazon S3: This option browses to the un-cached index.html in the root of your source bucket.

  • Launch from Amazon CloudFront: This option browses to the index.html that is cached on the CDN edge servers.

    Note

    Provisioning the edge locations for the distribution can take up to an hour. This link will not resolve until the distribution finishes propagating in the network.

  • Manage files: This option opens the Amazon S3 console to review and manage the contents of your source bucket. You can also find your bucket in the Amazon S3 console by opening your project in Mobile Hub and then choosing the Resources icon on the left. The name of the bucket configured for Hosting and Streaming contains the string hosting.

Managing Your App Assets

You can choose from a variety of ways to manage your web app assets through use of the Amazon S3 console, the AWS Command Line Interface (CLI) or one of the many third party applications available.

Using the Amazon S3 Console

To use the Amazon S3 console to review, upload, move or delete your files stored in your bucket, navigate to the Amazon S3 console and choose the bucket whose name contains your project name. Your web app content will reside in the root folder.

Using AWS CLI

AWS CLI allows you to review, upload, move or delete your files stored in your bucket using the command line.

To install and configure the AWS CLI client, see Getting Set Up with the AWS Command Line Interface.

As an example, the sync command enables transfer of files to and from your local folder (source) and your bucket (destination).

$ aws s3 sync {source destination} [--options]

The following command syncs all files from your current local folder to the folder in your web app's bucket defined by path.

$ aws s3 sync . s3://my-web-app-bucket/path

To learn more about using AWS CLI to manage Amazon S3, see Using Amazon S3 with the AWS Command Line Interface

Using a Custom Domain for Your Web App

To configure your Hosting and Streaming CDN as the destination of your custom domain, see Routing Traffic to an Amazon CloudFront Web Distribution by Using Your Domain Name.

Viewing AWS Resources Provisioned for this Feature

The following image shows the Mobile HubResources pane displaying elements typically provisioned for the Hosting and Streaming feature.

Quickstart App Details

In the Mobile Hub quickstart app, the Hosting and Streaming demo lists a set of image files that can be downloaded and cached locally and displayed on the device. The user can also delete the local copy of the image files.