1

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:

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.

Community
  • 1
  • 1
oli_taz
  • 197
  • 1
  • 4
  • 18
  • Ok, this is silly. You want to avoid **both** server-side processing **and** client-side processing. And somehow it should upload files and generate thumbnails on the way. Please, make your constraints more reasonable. – Sergey Kovalev Dec 15 '16 at 19:10
  • @SergeyKovalev Yes, you make a reasonable point. I've updated my answer with the clarification. – oli_taz Dec 15 '16 at 19:27
  • 1
    Do you need to keep the original file resolution or would it be fine to shrink it in client side? I suggest using S3 events and lambda inside AWS to do the thumbnail and DB insert. In the meantime you can poll the server to see if it's done. – jfneis Dec 15 '16 at 22:09

0 Answers0