[英]Suggestions for uploading very large (> 1GB) files
I know that such type of questions exist in SF but they are very specific, I need a generic suggestion. 我知道SF中存在此类问题,但它们非常具体,我需要一个通用建议。 I need a feature for uploading user files which could be of size more that 1 GB.
我需要一个上传用户文件的功能,该文件的大小可能超过1 GB。 This feature will be an add-on to the existing file-upload feature present in the application which caters to smaller files.
此功能将作为应用程序中现有文件上传功能的附加组件,可满足较小文件的需要。 Now, here are some of the options
现在,这是一些选项
Please suggest. 请提出建议。
Moreover, I've to make sure that this upload process don't hamper the task of other users or in other words don't eat up other user's b/w. 此外,我必须确保此上传过程不会妨碍其他用户的任务,或者换句话说,不会占用其他用户的黑白照片。 Any mechanisms which can be done at n/w level to throttle such processes?
可以在n / w级别执行任何机制来限制此类进程吗?
Ultimately customer wanted to have FTP as an option. 最终,客户希望将FTP作为选项。 But I think the answer with handling files programmatically is also cool.
但我认为以编程方式处理文件的答案也很酷。
Use whatever client side language you want (a Java App, Flex, etc.), and push to the server with HTTP PUT
(no Flex) or POST
. 使用所需的任何客户端语言(Java App,Flex等),然后使用
HTTP PUT
(无Flex)或POST
推送到服务器。 In the server side Java code, regulate the flow of bytes in your input stream loop. 在服务器端Java代码中,调节输入流循环中的字节流。 A crude, simple, sample snippet that limits bandwidth to no faster than an average <= 10KB/second:
粗略,简单的示例代码段,其带宽限制不超过平均<= 10KB /秒:
InputStream is = request.getInputStream();
OutputStream os = new FileOutputStream(new File("myfile.bin"));
int bytesRead = 0;
byte[] payload = new byte[10240];
while (bytesRead >= 0) {
bytesRead = is.read(payload);
if (bytesRead > 0)
os.write(payload, 0, bytesRead);
Thread.currentThread().sleep(1000);
}
(With more complexity one could more accurately regulate the single stream bandwidth, but it gets complex when considering socket buffers and such. "Good enough" is usually good enough.) (具有更高的复杂性,它可以更准确地调节单个流的带宽,但是在考虑套接字缓冲区时,它会变得复杂。“足够好”通常就足够了。)
My application does something similar to the above--we regulate both up ( POST
and PUT
) and ( GET
) down stream bandwidth. 我的应用程序执行了与上述操作类似的操作-我们同时调节(
POST
和PUT
)和( GET
)下行带宽。 We accept files in the 100s of MB every day and have tested up to 2GB. 我们每天接受100兆MB的文件,并且已经测试了2GB。 (Beyond 2GB there is the pesky Java int primitive issues to deal with.) Our clients are both Flex and
curl
. (除了2GB之外,还有一些讨厌的Java int基本问题要处理。)我们的客户都是Flex和
curl
。 It works for me, it can work for you. 它对我有用,对您也可以有用。
While FTP is great and all, you can avoid many (but not all) firewall issues by using HTTP. 尽管FTP很棒,而且很重要,但是您可以使用HTTP避免许多(但不是全部)防火墙问题。
如果要减少带宽,则可能要发送压缩的数据(除非已压缩),这可能节省2-3倍的数据量,具体取决于要发送的数据。
For an example of good practice for uploading large files, and the various ways of tackling it, have a look at flickr.com (you may have to sign up to get to the uploader page) 有关上传大文件以及解决该文件的各种方式的良好做法示例,请访问flickr.com(您可能需要注册才能进入上载器页面)
They provide various options, including HTTP form upload, a java desktop client, or some kind of javascript-driven gadget that I can't quite figure out. 它们提供了各种选项,包括HTTP表单上传,Java桌面客户端或我无法弄清楚的某种javascript驱动的小工具。 They don't seem to use flash anywhere.
他们似乎不在任何地方使用闪光灯。
For sending files to a server, unless you have to use HTTP, FTP is the way to go. 为了将文件发送到服务器,除非必须使用HTTP,否则FTP是必经之路。 Throttling, I am not completely sure of, at least not programmatically.
节流,我不确定,至少不是以编程方式。
Personally, it seems like limitations of the upload speed would be better accomplished on the server side though. 就个人而言,似乎可以在服务器端更好地完成上传速度的限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.