简体   繁体   English

有关上传非常大(> 1GB)文件的建议

[英]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 现在,这是一些选项

  1. Use HTTP and Java applet. 使用HTTP和Java小程序。 Send the files in chunks and join them at the server. 分块发送文件,然后将其加入服务器。 But how to throttle the n/w. 但是,如何限制n / w。
  2. Use HTTP and Flex application. 使用HTTP和Flex应用程序。 Is it better than an applet wrt browser compatibility & any other environment issues? 它比具有浏览器兼容性和任何其他环境问题的applet更好吗?
  3. Use FTP or rather SFTP rather than HTTP as a protocol for faster upload process 使用FTP或更确切地说是SFTP而不是HTTP作为协议,以加快上传过程

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. 我的应用程序执行了与上述操作类似的操作-我们同时调节( POSTPUT )和( 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.

相关问题 弹簧休息:通过休息控制器上传大文件(1GB) - spring rest: uploading large files (1GB) via rest controller Java压缩/解压缩大文件(&gt; 1gb) - Java compress/decompress large files (>1gb) 使用 Java NIO 读写大文件(&gt;1Gb)合适吗? - Reading and Writing large files (>1Gb) using Java NIO suitable? 无法在Java中将大文件(&gt; 1gb)转换为字节数组 - Unable to convert large files (>1gb) to byte array in java 使用java将大型(> 1GB)文件上载到服务器 - Upload large size( >1GB) file to server using java 创建大文件的最有效方法(&gt; 1GB) - Most efficient way to create a large file (> 1GB) 使用 http 协议、java 和 javascript 下载大于 1GB 的大文件 - Download large file >1GB using http protocol, java and javascript 使用 Java 在 Amazon S3 上上传大尺寸(超过 1 GB)文件:大文件临时占用服务器中的大量空间 - Uploading large size (more than 1 GB) file on Amazon S3 using Java: Large files temporary consuming lot of space in server 如何从Java生成大型(1gb)示例gc日志文件 - How to generate large(1gb) sample gc log file from Java 使用HttpClient上传大文件 - Uploading large files with HttpClient
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM