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

发布于 2024-07-25 19:52:28 字数 471 浏览 3 评论 0原文

我知道 SF 中存在此类问题,但它们非常具体,我需要一个通用的建议。 我需要一个用于上传大小可能超过 1 GB 的用户文件的功能。 此功能将是应用程序中现有文件上传功能的附加功能,可满足较小的文件需求。 现在,这里有一些选项

  1. 使用 HTTP 和 Java applet。 以块的形式发送文件并在服务器上将它们连接起来。 但如何限制n/w。
  2. 使用 HTTP 和 Flex 应用程序。 它比小程序与浏览器兼容性和兼容性更好吗? 还有其他环境问题吗?
  3. 使用 FTP 或 SFTP 而不是 HTTP 作为更快上传过程的协议

请建议

。 此外,我必须确保此上传过程不会妨碍其他用户的任务,或者换句话说,不会占用其他用户的黑白。 有什么机制可以在 n/w 级别上完成来限制此类进程?

最终客户希望将 FTP 作为一种选择。 但我认为以编程方式处理文件的答案也很酷。

I know that such type of questions exist in SF but they are very specific, I need a generic suggestion. I need a feature for uploading user files which could be of size more that 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. Send the files in chunks and join them at the server. But how to throttle the n/w.
  2. Use HTTP and Flex application. Is it better than an applet wrt browser compatibility & any other environment issues?
  3. Use FTP or rather SFTP rather than HTTP as a protocol for faster upload process

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?

Ultimately customer wanted to have FTP as an option. But I think the answer with handling files programmatically is also cool.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

热鲨 2024-08-01 19:52:29

使用您想要的任何客户端语言(Java 应用程序、Flex 等),并使用 HTTP PUT(无 Flex)或 POST 推送到服务器。 在服务器端 Java 代码中,调节输入流循环中的字节流。 一个粗略、简单的示例片段,将带宽限制为不超过平均 <= 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);
}

(复杂性越高,可以更准确地调节单流带宽,但在考虑套接字缓冲区等时,它会变得复杂。“足够好”通常已经足够好了。)

我的应用程序执行与上面类似的操作 - 我们同时调节 up (POSTPUT) 和 ( GET)下行带宽。 我们每天接受数百 MB 的文件,经测试最大可达 2GB。 (超过 2GB 还需要处理烦人的 Java int 原语问题。)我们的客户都是 Flex 和 curl。 它对我有用,对你也有用。

虽然 FTP 非常出色,但您可以通过使用 HTTP 来避免许多(但不是全部)防火墙问题。

Use whatever client side language you want (a Java App, Flex, etc.), and push to the server with HTTP PUT (no Flex) or POST. In the server side Java code, regulate the flow of bytes in your input stream loop. A crude, simple, sample snippet that limits bandwidth to no faster than an average <= 10KB/second:

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. We accept files in the 100s of MB every day and have tested up to 2GB. (Beyond 2GB there is the pesky Java int primitive issues to deal with.) Our clients are both Flex and 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.

扭转时空 2024-08-01 19:52:29

如果您想减少带宽,您可能需要发送压缩的数据(除非已经压缩),这可能会节省 2-3 倍的数据量,具体取决于您发送的内容。

If you want to reduce bandwidth you may want to send the data compressed (unless its compressed already) This may save 2-3 times the data volume depending on what you are sending.

请远离我 2024-08-01 19:52:29

有关上传大文件的良好实践示例以及解决该问题的各种方法,请查看 flickr.com(您可能需要注册才能访问上传程序页面)

它们提供了各种选项,包括 HTTP 表单上传、 java桌面客户端,或者某种我不太明白的javascript驱动的小工具。 他们似乎没有在任何地方使用闪光灯。

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)

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. They don't seem to use flash anywhere.

雨的味道风的声音 2024-08-01 19:52:29

要将文件发送到服务器,除非您必须使用 HTTP,否则 FTP 是最佳选择。 节流,我不完全确定,至少不是以编程方式。

就个人而言,似乎上传速度的限制在服务器端会更好地实现。

For sending files to a server, unless you have to use HTTP, FTP is the way to go. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文