讀取資料庫二進位制視訊並返回路徑
阿新 • • 發佈:2021-01-14
var virpath1 = "/upload/video/"; string dirFullPath1 = Server.MapPath(virpath1); var video = VideoHelper.GetProductVideoUrl(dirFullPath1, virpath1, model.video, videoName); public static string GetProductVideoUrl(string dirFullPath, string virpath, byte[] model, string qrCode) { if (model == null) { return ""; } else { if (!Directory.Exists(dirFullPath))//如果資料夾不存在,則先建立資料夾 { Directory.CreateDirectory(dirFullPath); } var fileName = qrCode; dirFullPath = dirFullPath + fileName; if (!File.Exists(dirFullPath)) { SaveToVideo(dirFullPath, model); } var url = WebConfigurationManager.AppSettings["hostUrl"].ToString(); return url + virpath + fileName; } } private static void SaveToVideo(string path, byte[] bytes) { FileStream fs = new FileStream(path, FileMode.CreateNew); fs.Write(bytes, 0, bytes.Length); fs.Close(); }