I am building an app using ASP.NET C# MVC5. You can add records to a database and these records can have images attached to them (it can be a single image for now if it makes it more complex).
I have seen some other posts on storage uploads but I don't see them working for me:
- Upload File to Amazon S3
- Upload files directly to Amazon S3 from ASP.NET application
- How to upload a file to amazon S3 without passing it by a server?
Idea:
- Upload a file (image) to Amazon S3 without the data passing through my server.
- Persist any data on the form that was entered by the user (I'm happy with a post-back, modal or no-refreshing of the page)
- Save a database value in a File table with the name and type of the file etc. that was uploaded (this will also be linked to the item that they are associated with)
Process:
- User selects file to upload and presses upload button
- File is uploaded directly to amazon (c# async method?, ajax?)
- Thumbnail version is also created and uploaded to amazon using the same method? ('-thumb' is appended to filename)
- Database records created with filename, amazon fileKey, fileType etc. for both files
- (optional) thumbnail is then shown on-screen next to the uploader
- User presses 'Save' to save the record along with the image information
When the user goes to save the item information (could be creating a new record or editing an existing one), the file information can be attached (if it isn't attached at the point of uploading the file??)
Constraints:
- Avoid using client-based solution for improved app performance and accessibility across platforms (so avoid JavaScript, and definitely flash)
- Minimise possibility of the user uploading a file and forgetting to save (or the browser crashing and loosing the link to the file that has been uploaded)
If I knew more about ASP.NET MVC I would have liked to have more suggestions or ideas. I wonder about using async methods or ajax calls to stop the page re-loading and loosing inputted data.
I have downloaded the Amazon SDK and built some classes around it but realised that it wasn't that useful if I'm not uploading via my app! I took samples for client side upload from https://github.com/floatingfrisbee/amazonfileupload which was fairly useful (I managed to get it working in my app for client side uploads) but there is a lot missing from that solution to fit my problem and I would like a neat, reliable solution for my more complex problem.
Any ideas very welcome!! I'm really struggling to come up with something.
UPDATE 15.12.2016 To clarify, I would like to minimise the amount of client-side processing to the point that a low powered mobile device wouldn't struggle to process the request (obviously if the device can't handle simple image uploads then I don't need to worry). In terms of server-side processing, the main thing I want to avoid is uploading the image via the server for bandwidth reasons, any other processing I am very happy to happen on the server.