Skip to content

Setting up External Services

Vangelis Tsoumenis edited this page May 9, 2014 · 16 revisions

Pageflow uses three external Services to deal with the content for the presentations.

  • Amazon S3 to host its Videos, Pictures and Audios.
  • Zencoder to encode the content to fit the different formats needed.
  • (In production environment) Amazon Cloudfront. A CDN to speed up access to the content.

Please create accounts for Amazon AWS and Zencoder.

Files that are uploaded to be used in Pageflow will be stored in an S3 bucket. Zencoder takes them from there, encodes the files and stores them in a second bucket. The website displays the content from this second bucket via Cloudfront.

Amazon S3

Thus, two Amazon S3 buckets are needed are needed for each environment.

  • Main bucket for paperclip attachments and Zencoder to read from.
  • Output bucket for Zencoder to write encoded files to.

For example:

  • de-mycompany-pageflow-production
  • de-mycompany-pageflow-production-out
  • de-mycompany-pageflow-development
  • de-mycompany-pageflow-development-out

You can add buckets for staging or other deployment environments. Multiple developers can share the same development buckets because files in this buckets are namespaced by the hostname of the developer's machine.

Hint: Its better to use dashes - than dots .. Dots can cause trouble when using https.

Bucket Configuration

  • Add the permissions View for Everyone for both buckets.
    • Go to Properties -> Permission
    • Click "Add more permissions"
    • Selecy "Everyone" from drop-down and click "View"
    • Save
  • Configure static website hosting for each bucket.
    • Go to Properties -> Static Website Hosting
    • Click "Enable Static Website Hosting".
    • Enter arbitrary string into the field "Index Document" (i.e. "foo", you can't save without this)
    • Click "Save"
  • Grant Zencoder access to the buckets by adding the Zencoder Bucket Policies.
    • Go to Properties -> Permissions.
    • Click "Edit bucket policy".
    • Copy the correct JSON snippet from Zencoder Bucket Policies (Main or Output)
    • Replace the <main bucket> or <output bucket> placeholders with the full bucket name.
    • Click "Save"

Bandwidth Detection

Pageflow measures the download times of some static files to detect the bandwidth of the client.

The following files have to be placed in the Output ("-out") bucket:

Zencoder

Get your API Key from Zencoder and make sure it is used in the zencoder_options in config/initializers/pageflow.rb.

Note that Zencoder offers a special "Integration API Key" that can be used free of charge during development. Encoded files are cropped at five seconds.

Amazon Cloudfront

Create three distributions:

  • one for each of the two S3 buckets
  • one for which has the rails app itself as origin

Configure CNAMES and make sure they are used in config/initializers/pageflow.rb as s3_host_alias in production mode. Please see the inline docs and examples in config/initializers/pageflow.rb.