//C:\Users\Eminent\Documents\Projects\perception\CMS\CMS\CMS\Files\_originals\Koala.jpg //string strPath = HttpContext.Current.Server.MapPath("/Files/_originals/Koala.jpg"); public Values.AddFile SaveFile(IConnectToDB _Connect, IFormFile File) { add addHelp = new add(); string ContentType = File.ContentType; long? ContentSize = File.Length; string FileName = File.FileName; byte[] longRaw = new byte[File.Length]; //TODO: Review .Net Core Port if (File.Length > 0) { using (var ms = new MemoryStream()) { File.CopyTo(ms); longRaw = ms.ToArray(); //string s = Convert.ToBase64String(fileBytes); // act on the Base64 data } } Values.AddFile thisFile = addHelp.ADD_ENTRY_FILE(_Connect, new Values.AddFile { I_FILE_NAME = FileName, I_CONTENT_TYPE = ContentType, I_FILE_SIZE = ContentSize, I_FILE_DATA = longRaw }); return(thisFile); }
public Values.AddFile SaveFile(IConnectToDB _Connect, string filename, string filedata) { add addHelp = new add(); string[] ext = filename.Split('.'); //string ContentType = GetContentTypeViaExt(ext[1]); string ContentType = System.IO.Path.GetExtension(System.IO.Path.GetFileName(filename)); byte[] imgbytes = getBytes(filedata); long? ContentSize = imgbytes.Length; string FileName = filename; Values.AddFile thisFile = addHelp.ADD_ENTRY_FILE(_Connect, new Values.AddFile { I_FILE_NAME = FileName, I_CONTENT_TYPE = ContentType, I_FILE_SIZE = ContentSize, I_FILE_DATA = imgbytes }); return(thisFile); }