Skip to content

Latest commit

 

History

History
99 lines (74 loc) · 3.41 KB

README.textile

File metadata and controls

99 lines (74 loc) · 3.41 KB

Condo Example App

A basic implementation of Condo to demonstrate uploading files directly from the browser to Amazon S3 or Google Cloud Storage

  • Supports drag and drop (with folders)
  • Multiple uploads (can easily handle 1000’s of files)
  • Pause / Resume functionality (Resumable and chunked uploads are available on Amazon for files over 5MB.)

Usage

  1. Clone repository onto your system
  2. Edit config/initializers/condo_providers.rb
  3. Edit app/controllers/uploads_controller.rb
    • set_callback :bucket_name should be set to an existing bucket
    • configuring your provider (see below)
  4. Set the required environmental variables with your providers security keys
    • As defined in condo_providers.rb
  5. bundle install
  6. rake db:migrate
  7. rails server
  8. Browse to: http://localhost:3000/

Configuring your provider

Amazon

  1. Enable CORS at the bucket level

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>http://localhost:3000</AllowedOrigin>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
    </CORSRule>
</CORSConfiguration>

You may want to apply similar configurations programmatically in production, especially if you have a bucket per-user.

Google

  1. Enable ‘Interoperable Storage Access’ on your application
  2. Enable CORS at the bucket level – Googles documentation

<?xml version="1.0" encoding="UTF-8"?>
<CorsConfig>
  <Cors>
    <Origins>
      <Origin>http://localhost:3000</Origin>
    </Origins>
    <Methods>
      <Method>GET</Method>
      <Method>HEAD</Method>
      <Method>POST</Method>
      <Method>PUT</Method>
    </Methods>
    <ResponseHeaders>
      <ResponseHeader>origin</ResponseHeader>
      <ResponseHeader>content-md5</ResponseHeader>
      <ResponseHeader>authorization</ResponseHeader>
      <ResponseHeader>x-goog-date</ResponseHeader>
      <ResponseHeader>x-goog-acl</ResponseHeader>
      <ResponseHeader>content-type</ResponseHeader>
      <ResponseHeader>accept</ResponseHeader>
      <ResponseHeader>x-goog-api-version</ResponseHeader>
      <ResponseHeader>x-goog-resumable</ResponseHeader>
      <ResponseHeader>ETag</ResponseHeader>
    </ResponseHeaders>
    <MaxAgeSec>1800</MaxAgeSec>
  </Cors>
</CorsConfig>

I wrote a helper function in Condo for applying this using Fog

Rackspace

If you do want to use it you’ll have to enable temporary URLs you need to set a metadata header on your account.
There is also a helper function in Condo that achieves this using Fog.
You’ll also need to enable CORS: http://docs.rackspace.com/files/api/v1/cf-devguide/content/CORS_Container_Header-d1e1300.html