I’m implementing a file upload feature, and want to pass the uploaded file from the controller to a service layer that will do the processing (saving to disc, db updates etc).
I’m following Phil Haacked’s example:
http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx
The uploaded file is coming into the Controller’s Action method as a parameter of type
System.Web.HttpPostedFileBase.
I could simply pass this parameter directly to the service layer and call all the convenient methods and properties from it to get the job done, but I would rather not have my service layer have a dependency on System.Web.
Is there a better or “Standard” datatype to chose when passing file content and file metadata (E.G. Filename) in a .Net application?
Typically, I’ve always used a
StreamorByte[]to transfer files. Metadata (at least the relevant information I want to keep) are separate parameters. If you choose to go this route, may I also recommend passing a SHA-1 or another type of hash to verify file integrity.