/// <summary> /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler" /> interface. /// </summary> /// <param name="context">An <see cref="T:System.Web.HttpContext" /> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param> public void ProcessRequest(HttpContext context) { //Image formats //jpg, jpeg, png, gif, tiff //Documents Formats //PDF, doc, docx, text var file = context.Request.Files[FormConstants.UploadParameterName]; var albumId = context.Request[FormConstants.AlbumIdParameterName]; var bytes = GetBytes(file); var username = BaseController.AuthenticatedUsername(); var extension = Path.GetExtension(file.FileName).Replace(".", string.Empty); var id = Guid.NewGuid(); var media = new MediaMessage { AlbumId = (string.IsNullOrEmpty(albumId) ? null : (int?)Convert.ToInt32(albumId)), Extension = extension, Filename = file.FileName, Id = id, Size = bytes.Length, Username = username }; _repository.Save(new SaveMediaParameters(id, bytes, media)); }