Skip to content

Instantly share code, notes, and snippets.

@dacur
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save dacur/1106854bf141eb222452 to your computer and use it in GitHub Desktop.

Select an option

Save dacur/1106854bf141eb222452 to your computer and use it in GitHub Desktop.
Steps for image uploads in a Rails application.
1. Create bucket in Amazon AWS/S3. Choose US Standard.
2. Add More Permissions => Grantee: Everyone; Check 'List' and 'Upload/Delete'.
3. Edit Bucket Policy. Edit CORS Configuration. See uploads.js gist for code.
******
4. Add dropzone.js file, get contents from dropzone website.
5. Add 'require dropzone' to application.js file.
6. Add uploads.js file to hold dropzone code. See uploads.js gist for code.
******
7. Add #primaryImage div to view. This will be the target for the dropzone.
8. Add 'process' method from uploads.js gist to controller. Add route for /process.
!NOTE: You cannot have a method named 'process' in your main_controller. Rename method to 'upload' to avoid Rails conflicts! Make sure if you rename to fix it throughout your code.
9. Add 'dropzonejs-rails' and 'aws-sdk' gems to gem file. Bundle install.
******
10. Create 'aws.yml' file. Insert access and secret access info. See gist.
11. Include link to font-awesome CDN in application.html.haml file.
12. Add DropZone CSS.
13. Create an 'images' folder in the 'public' rails folder. Put two sprite images there for DropZone.
******
14. Controller returns AmazonURL/name to uploads.js. Save it in hdnDiv. See gist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment