[英]What is the correct/proper way to upload files to a server?
What is the correct/proper way to upload files to a server? 将文件上传到服务器的正确/正确方法是什么? I'm only talking about small files such as images, text files, and excel/word files.
我只是在谈论小文件,例如图像,文本文件和excel / word文件。
I know that I can upload images to the database using BLOB. 我知道我可以使用BLOB将图像上传到数据库。 But what about the others?
但是其他呢?
I have a table called "Ticket" which contains information such as date created, ticket number, caller, attachment , and etc. 我有一个名为“ Ticket”的表,其中包含诸如创建日期,票证编号,呼叫者, 附件等信息。
I'm having problems on how to upload an attachment to a server. 我在如何将附件上载到服务器时遇到问题。
The first option should be uploading the image to a file server and stored the file id or uuid in your ticket table, or a OneToMany table stores all attachments. 第一个选项应该是将映像上传到文件服务器,并将文件ID或uuid存储在票证表中,或者OneToMany表存储所有附件。
Always void using BLOB to store image binary in database. 使用BLOB将图像二进制文件存储在数据库中时始终无效。 Database has this capability doesn't mean it's a good way to use it.
数据库具有此功能并不意味着它是使用它的好方法。
If you are working on a small project, you may not see the problem. 如果您正在处理一个小型项目,则可能看不到该问题。 If the concurrent is relatively high,
如果并发比较高,
Imagine you store the files in the database, even all are just images, whenever you retrieve the tickets, the a-few-MB image will be in the memory. 想象一下,您将文件存储在数据库中,甚至所有文件都只是图像,每当您检索票证时,几个MB的图像就会存储在内存中。 It's a waste of server memory.
这浪费了服务器内存。
If you are using some ORM to retrieve the list, which will be worst and your server can be easily OutOfMemory. 如果您正在使用某些ORM来检索列表,那将是最糟糕的情况,并且您的服务器可能很容易内存不足。
One more thing is that if your system has Web Application Firewall in front, it's also advisable to separate file upload with normal form submission. 还有一件事是,如果您的系统前面有Web应用程序防火墙,则建议将文件上传与常规表单提交分开。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.