private BaseUploadFile ConvertToUploadFile(byte[] file, string ext) { BaseUploadFile UploadFile = UploadFileFactory.CreateInstance("", ext); MemoryStream memoryStream = new MemoryStream(); memoryStream.Write(file, 0, file.Length); UploadFile.InputStream = memoryStream; UploadFile.ExtensionName = ext; UploadFile.FileName = Guid.NewGuid() + "." + UploadFile.ExtensionName; return(BaseConvertToUploadFile(UploadFile)); }
private BaseUploadFile ConvertToUploadFile(HttpPostedFileBase file) { string ext = file.FileName.Substring(file.FileName.LastIndexOf(".") + 1); BaseUploadFile UploadFile = UploadFileFactory.CreateInstance(file.ContentType, ext); UploadFile.OriginalFile = file; UploadFile.InputStream = file.InputStream; UploadFile.ExtensionName = ext; UploadFile.FileName = (this.RandomFileName ? Guid.NewGuid() + "." + UploadFile.ExtensionName : file.FileName); UploadFile.FileLength = file.ContentLength; UploadFile.MIMEType = file.ContentType; return(BaseConvertToUploadFile(UploadFile)); }