简体   繁体   English

将文件上传到服务器的正确/正确方法是什么?

[英]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.

相关问题 通过改造上传大型Base64编码文件的正确方法是什么? - What is the correct way to upload large Base64 encoded files with retrofit? 处理大文件的正确方法是什么? - What is the proper way to handle large files? 在Maven中替换文件的正确方法是什么? - What is the proper way to replace files in Maven? 在项目中指定XSD schemaLocation的正确或适当方法是什么? - What's the correct or proper way to specify XSD schemaLocation across projects? 从套接字读取文件的正确方法是什么? - What is the correct way of reading files in from the socket? 部署具有JSON文件的Java项目的正确方法是什么? - What is the proper way to deploy Java project that has JSON files? 应用程序启动后,在服务器中创建文件的正确方法是什么? - What is the proper way to create a file in your server after the application starts? 轮询客户端连接的正确方法是什么 — Apache Thrift Server - What is the Proper way to Poll for Client Connections — Apache Thrift Server 正常关闭Grizzly服务器的正确方法是什么? (嵌入泽西岛) - What is the proper way to gracefully shutdown a Grizzly server? (Embedded with Jersey) 使用SimpleFTP从FTP服务器断开连接的正确方法是什么? - What is the proper way to disconnect from an FTP server using SimpleFTP?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM