示例#1
0
        public void PopulateVideoPreview(HttpContext context, long fileId)
        {
            try
            {
                context.Response.Clear();

                FileLibrary      lib      = new FileLibrary();
                VideoFileLibrary videoLib = new VideoFileLibrary();

                AWAPI_Data.Data.awFile file = lib.Get(fileId);
                string extension            = FileLibrary.GetFileExension(file.path);

                if (file == null || !videoLib.isVideoFile(extension))
                {
                    return;
                }

                if (!file.isOnLocal)
                {
                    context.Response.Redirect(file.thumbnail);
                    return;
                }

                if (!System.IO.File.Exists(file.thumbnail))
                {
                    return;
                }

                context.Response.ContentType = "image/jpeg";
                context.Response.AddHeader("Content-Disposition", "inline; filename=" + file.title + "_preview.jpg");

                byte[] bytes = File.ReadAllBytes(file.thumbnail);

                context.Response.OutputStream.Write(bytes, 0, bytes.Length);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }