Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (24 sloc) 1.878 kB

S3 Uploader Asp.Net MVC Example

MVC port of Nico Ritsche's (github.com/ncri) multiple file S3 uploader Rails example, which can be found at github.com/ncri/s3_uploader_example

And based on the great jQuery File Upload plugin: blueimp.github.com/jQuery-File-Upload/

  • Upload multiple files straight to S3 from within the browser without hitting the server first

  • Gets around S3's lacking cross domain access header support by storing the upload form on s3, embedded in an iframe.

  • Upload progress is displayed on the host server by utilizing postMessage browser communication.

  • After a file is uploaded a post ajax request is made to create a resource for the uploaded file in the db.

Getting Started

  1. Build S3Uploader/S3Uploader.sln (make sure nuget package restore pulls all the dependencies down that you need)

  2. Fill in the AWS S3 config variables within S3Uploader/S3PrepTask/App.config and S3Uploader/S3Uploader/Web.config:

    AWSAccessKey
    AWSSecretKey
    AWSBucket
    AWSUploaderPath
  3. Set your server host in S3Uploader/S3Uploader/Scripts/s3_uploader/s3_uploader.js:

    var host = 'http://yourdomain.com';
  4. Deploy uploader javascript and form to s3 (run in command prompt)

    Open command prompt and run S3Uploader/S3PrepTask/bin/{debug or release}/S3PrepTask.exe
  5. Start web app and Upload All the Things!!! :)

Notes

  • The path for the uploaded files defaults to “uploads/:uuid” (see UploadsController). Currently the path must have the :uuid placeholder in it. It is replaced with a random string for each uploaded file, to obfuscate the file locations and to prevent overwriting existing files.

  • To compile coffeescript into javascript within visual studio, install the recommended Mindscape Web Workbench extension: visualstudiogallery.msdn.microsoft.com/2b96d16a-c986-4501-8f97-8008f9db141a

Jump to Line
Something went wrong with that request. Please try again.