I am building an image management tool and I want to know how I can create a Vimeo-like experience.
Description of what needs to happen
The user will be able to upload many potentially large images using plupload (no page reload). Then the server will take the following actions on each uploaded image.
- The image will be resized into several versions (e.g. thumb, small, medium, large)
- Each copy will have some image processing done (e.g. convolution filter)
- These resized copies will be uploaded to Amazon S3
- Info about each image will be stored to a database (width, height, mimetype, filename)
- Then the server should trigger some sort of feedback to the user
Providing Asyncronous Feedback
Plupload (image uploading tool) has really nice visual feedback when uploading the files to my server, however, I want to be able to give additional feedback to the user while the server is doing all the image processing and uploading to remote storage.
Vimeo does this nicely. When you upload a video it gives confirmation that it has been uploaded, but then says "we are encoding your video, please wait" and the UI gives some sort of progress indicator.
I would like to give the user two kinds of feedback after the images have been uploaded to my server. Each time an image has been processed and uploaded to S3 I would like to:
- Update a message on the browser saying "5 of 15 images have been processed" and I would like to
- Have a thumbnail of that image appear.
An Example MVC Controller Action
[HttpPost]
public virtual ContentResult Upload(Guid albumId)
{
foreach (string file in Request.Files)
{
HttpPostedFileBase f = Request.Files[file] as HttpPostedFileBase;
if (f.ContentLength == 0)
continue;
var uploadDir = Server.MapPath("~/uploads/"+ albumId);
var filePath = Path.Combine(uploadDir, Path.GetFileName(hpf.FileName));
f.SaveAs(filePath);
// How can I trigger some async task here that would be able
// to trigger some sort of feedback to the browser when complete?
SomeAsyncImageProcessor.ProcessImage(albumId, filePath); // ???
}
return Content("Success", "text/plain");
}
Constraints
The people using this web app will be using the latest version of Chrome. No cross-browser issues need to be addressed. We are using asp.net MVC 3 and SQL Server 2005
Can anyone point me in the right direction? Are there any great resources out there to show how I can accomplish something like this?