Sql Server 2012 存储pdf [英] Sql Server 2012 store pdf

查看:68
本文介绍了Sql Server 2012 存储pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在数据库中存储 PDF 文件以及如何使用 asp.net 显示预览.PDF文件由控件上传,然后我需要显示预览,然后我存储到数据库中.

How to store PDFs file in database and how to show preview using the asp.net. the PDFs file is uploaded by control and then i need to show preview afterward i store into the database.

    <input type="file" />

推荐答案

通常,您可以选择以下技术之一:

Generally, you can choose one of the following techniques:

  • 将文件上传到服务器的特定文件夹中,并仅将文件的 URL 存储在数据库中.之后,使用 URL 显示或下载文件
  • BLOB (Binary Large OBject) 字段中上传文件并存储在数据库中
  • Upload the file in specific folder in your server and store in your database only the URL to the file. Latter, use the URL for showing or downloading the file
  • Upload the file and store in the database in BLOB (Binary Large OBject) field

每一个都有优点和缺点,这取决于你的情况,你可以决定使用哪种技术.

Each of these, has advantages and disadvantages and it is up to your situation and you to decided which technique for use.

幸运的是,当我们使用 SQL Server 存储文件时,我们还有一个选项可以带来更好的性能 - 文件流存储.

Fortunately, when we are using SQL Server for storing files we have one more option which can lead to better performance - Filestream Storage.

建议在以下情况下使用这种类型的存储:

This type of storage is recommended in the following situations:

  • 存储的对象平均大于 1 MB.
  • 快速读取访问很重要.
  • 您正在开发使用中间层的应用程序应用逻辑

因为很少有 PDF 文件小于 1 MB,我相信您应该使用这种技术,但是:

Since, rarely PDF files are smaller then 1 MB, I believe you should use this technique but:

对于较小的对象,在数据库中存储 varbinary(max) BLOB通常提供更好的流媒体性能.

For smaller objects, storing varbinary(max) BLOBs in the database often provides better streaming performance.

您可以查看以下 教程以激活存储.

You can check the following this tutorial in order to activate the storage.

这篇关于Sql Server 2012 存储pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆