Exemplo n.º 1
0
 /// <summary>
 /// 由由SQL中讀出PDF內容, 並顯示在瀏覽器上
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult Show(int id)
 {
     using (var db = new SignedContractContext())
     {
         var entry = db.SignedContracts.Find(id);
         return(File(entry.SignedFile, "application/pdf"));
     }
 }
Exemplo n.º 2
0
 public ActionResult Pdfs()
 {
     using (var db = new SignedContractContext())
     {
         var pdfs = db.SignedContracts.ToList();
         return(View(pdfs));
     }
 }
Exemplo n.º 3
0
 public HttpResponseMessage PdfGet(int id)
 {
     using (var db = new SignedContractContext())
     {
         var entry = db.SignedContracts.Find(id);
         HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
         result.Content = new StreamContent(new MemoryStream(entry.SignedFile));
         result.Content.Headers.ContentType =
             new MediaTypeHeaderValue("application/pdf");
         return(result);
     }
 }
Exemplo n.º 4
0
        public ActionResult Index(PostFiles model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var storeFile = new SignedContract();

            storeFile.SignedFile = new byte[model.File.InputStream.Length];
            storeFile.FileName   = model.File.FileName;
            model.File.InputStream.Read(storeFile.SignedFile, 0, storeFile.SignedFile.Length);

            using (var db = new SignedContractContext())
            {
                db.SignedContracts.Add(storeFile);
                db.SaveChanges();
            }
            // now you could pass the byte array to your model and store wherever
            // you intended to store it

            return(Content("Thanks for uploading the file"));
        }