存储上传到我网站的大文件 [英] storing of large files uploaded in my website

查看:66
本文介绍了存储上传到我网站的大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我正在创建一个网站,让地下和本地艺术家分享音乐节拍我已通过一些博客阅读并明确说明在他们中,不建议在数据库中存储大尺寸的数据,并且他们说最好存储在目录中并且我已经研究过但我仍然不了解专业人员的缺点和方法它完成了...我需要一个安全可靠的方法/地方来存储上传的文件,因为一些未签约的生产者希望选择销售并免费赠送节拍。我不确定我是否对我的问题很清楚因为我现在也有点困惑...我希望用户能够做的是在我的网站上传和下载媒体文件



提前谢谢

Hi all

I am creating a website that enables underground and local artist to share music beats I''ve read through a few blogs and its been clearly stated in them that storing data of large sizes in a database is not advised and they say that its better to store in a directory and I''ve researched around that but I still don''t understand the pro''s and cons and how its done... I need a safe and secure method/place to store uploaded files because some of the unsigned producers want the option to sell and give away beats for free. I''m not sure if I''m clear enough on my question cause I''m also confused a bit now... What I want the user to be able to do is upload and download media files on my website

Thanks in advance

推荐答案

将数据本身存储在数据库中有几个很好的理由,它们都涉及相关项目的大小。



直到最近,数据库文件的最大大小限制在16GB - 这被提升为对于任何人(谷歌可能例外),524,272太字节应该足够了几年。



但是......这并不代表你应该开始为网站存储大型对象。

问题是这里至少涉及三台计算机:SQL服务器读取数据并将其传输(通常通过1GBit / sec LAN)到运行站点应用程序的Web服务器,其中包含tr通过一个更慢的链接到您的客户端来解决它。这会占用带宽(或Web服务器内存),就像疯了一样 - 开始同时传输两个大文件,并且事情开始变得棘手,并且SQL连接(这是一种稀缺资源)必须保持到转移到Web服务器已完成。



如果您将文件作为文件存储在Web服务器上的文件夹中,那么数据已经是本地的,并且SQL没有参与。



我这样做的方法是拥有一个包含四列的数据库表:ID,原始文件名,插入日期和指向我的网络服务器中基于guid的文件名。 SQL查询很好而且快速(因为信息只是两个短字符串),文件本身可以从本地硬盘传输,客户端传递原始名称而不是内部名称。使用基于Guid的文件名的主要原因是为了确保两个不同的用户不保存相同的文件并相互覆盖。
There are a couple of good reasons for not storing the file itself in a database, and they both concern the size of the items concerned.

Until recently, the maximum size of a database file was restricted to a paltry 16GB - it was raised this to 524,272 terabytes which should be enough for anybody (with the possible exception of Google) for a couple of years.

But... that doesn''t mean that you should start storing large objects for a web site.
The problem is that you have at least three computers involved here: SQL server which reads the data and transfers it (normally via 1GBit/sec LAN) to the Webserver where your site application is running, which transfers it via a much slower link to your client. This takes up bandwidth (or web server memory) like crazy - start to transfer two large files at the same time and thing start to grind a bit, and the SQL connection (which is a scarce resource) has to be held until the transfer to the web server is complete.

If you are storing the file as a file in a folder on the Webserver, then the data is already local, and SQL does not have to be involved.

The way I do it is to have a DB table which holds four columns: ID, original file name, date inserted, and a link to a guid-based file name in my webserver. The SQL query is nice and quick,(since the info is just two short strings), and the file itself can be transferred from the local harddrive, with the client passed the original name instead of the internal one. The main reason for using Guid based file names is to ensure that two different users don''t save the same file and overwrite each other.


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

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