I am trying to upload a file and send it to the service level for saving, however I continue to find examples of how the controller receives the HTTPPostedFileBase and stores it directly in the controller. My service level has no limitations in web dll, so I need to read my object in a memory stream / byte? Any pointers on how I should do this are greatly appreciated ...
Note. Files can be written in pdf format, so I may also need to check the type of content (possibly within the domain level of the domain ...
the code:
public ActionResult UploadFile(string filename, HttpPostedFileBase thefile)
{
}
EDIT:
public interface ISomethingService
{
void AddFileToDisk(string loggedonuserid, int fileid, UploadedFile newupload);
}
public class UploadedFile
{
public string Filename { get; set; }
public Stream TheFile { get; set; }
public string ContentType { get; set; }
}
public class SomethingService : ISomethingService
{
public AddFileToDisk(string loggedonuserid, int fileid, UploadedFile newupload)
{
var path = @"c:\somewhere";
Image _image = Image.FromStream(file);
_image.Save(path);
}
}
source
share