cotag / condo_example

An example Condo app
14 stars 4 forks source link

h1. Condo Example App

A basic implementation of "Condo":https://github.com/cotag/Condominios to demonstrate uploading files directly from the browser to "Amazon S3":http://aws.amazon.com/s3/ or "Google Cloud Storage":https://cloud.google.com/products/cloud-storage

!https://raw.github.com/cotag/condo_example/master/doc/upload_screenshot.png!

h2. Usage

Clone repository onto your system

Edit @config/initializers/condo_providers.rb@

Edit @app/controllers/uploads_controller.rb@

* @set_callback :bucket_name@ should be set to an existing bucket

* configuring your provider (see below)

Set the required environmental variables with your providers security keys

* As defined in condo_providers.rb

@bundle install@

@rake db:migrate@

@rails server@

Browse to: http://localhost:3000/

h3. Configuring your provider

h4. Amazon

"Enable CORS":http://aws.typepad.com/aws/2012/08/amazon-s3-cross-origin-resource-sharing.html at the bucket level




    
        http://localhost:3000
        PUT
        POST
        *
    
    
        *
        GET
    


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

h4. Google

Enable 'Interoperable Storage Access' on your application

Enable CORS at the bucket level - "Googles documentation":https://developers.google.com/storage/docs/cross-origin




  
    
      http://localhost:3000
    
    
      GET
      HEAD
      POST
      PUT
    
    
      origin
      content-md5
      authorization
      x-goog-date
      x-goog-acl
      content-type
      accept
      x-goog-api-version
      x-goog-resumable
      ETag
    
    1800
  


I wrote a helper function in Condo for applying this using "Fog":http://fog.io/

h4. Rackspace

If you do want to use it you'll have to enable "temporary URLs":http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html you need to set a "metadata header":http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Account_Metadata-d1a4460.html 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