哪种文件上传协议(FTP / HTTP)对于高度不可靠的移动网络是有利的 [英] Which file upload protocol (FTP / HTTP) is good for mobile with highly unreliable network

查看:190
本文介绍了哪种文件上传协议(FTP / HTTP)对于高度不可靠的移动网络是有利的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究Android上的文件上传,发现HTTP和FTP都可以上传文件,但是HTTP本身是由Android支持的,但是FTP是通过 Apache commons library ,同样发现两者都有各自的优缺点,但不是从手机的角度来看,因为手机网络中断是非常普遍的,所以我的问题是这样的:

1)我应该坚持HTTP多部分文件上传,无论是在手机上还是使用FTP



2)我的服务器是FTP存储库,我仍然可以使用HTTP上传没有问题

3) FTP是否像HTTP一样使用分段上传,或者在频繁中断的情况下如何处理网络问题 解决方案


1)我应该坚持HTTP多部分文件上传,无论是在手机或使用FTP是好的




由于设计FTP在任何使用私有IPv4地址的网络中都是非常糟糕的选择 - 由于IPv4地址短缺,大多数移动网络可能都是这种情况。虽然它可能在一个网络内工作,但它不会在另一个网络中工作,如果您尝试将FTP与SSL结合起来,以确保传输更糟糕。通常没有问题的工作。通过使用Range请求,您还可以下载部分文件,这在重新开始破解下载或仅载入文档的必要部分(如大型PDF文件的一部分)时非常重要。 FTP具有有限的恢复能力,但不如HTTP范围请求有用。


至于恢复上传FTP有REST(重新启动)命令。但是您需要先了解在服务器上接收了多少数据,以便您知道重新启动的位置。 HTTP没有内置的恢复上传。您可以在POST或PUT请求中使用 Content-Range 头,但是您的服务器需要了解如何处理这个头。或者你可以将上传分散到多个请求中,这些请求又需要特殊的服务器端代码来重建服务器上的原始文件。



这两个协议的开销大致相同, 2)我的服务器是FTP存储库,我仍然可以使用HTTP上传没有问题,我可以忽略任何东西,但非常小的文件。



如果您的服务器没有HTTP接口,那么您不能使用HTTP。但是,只是FTP存储库的描述并没有提供足够的信息来获取它的方式。

lockquote
3)FTP使用多部分上传就像HTTP一样,或者在频繁中断的时候处理网络问题如何处理?b

如果断开了,你需要找出重新启动的地方与上传(检查远程长度),然后使用REST命令。

I have been working on File Upload in Android and found out both HTTP and FTP are available to do file upload, but HTTP is supported natively by Android , But FTP is through Apache commons library, also found out both has its own pros and cons but not in terms of mobile's perspective, because in mobiles network breaks is very common,

so my questions

1) Should I stick to HTTP multi-part file upload no matter what in mobiles or is it fine to use FTP

2) My Server is FTP storage repository, can I still use HTTP to upload without issue

3) Does FTP use multipart upload just like HTTP or how is network issues handled when there is frequent breaks

解决方案

1) Should I stick to HTTP multi-part file upload no matter what in mobiles or is it fine to use FTP

Because of the design FTP is a very bad choice in any networks which use private IPv4 addresses - which due to the shortage of IPv4 addresses is the case with probably most mobile networks. While it might work within one network it will not work within another and if you try to combine FTP with SSL to secure the transport it gets even worse.

HTTP and HTTPS instead work usually without problems. With the use of Range requests you also have the ability to download parts of files, which is important when resuming broken downloads or loading only the necessary parts of a document (like parts of an big PDF file). FTP has limited resume capability but not as useful as the HTTP Range request.

As for resuming uploads FTP has the REST (restart) command. But you need to first find out how much data were received at the server so that you know where to restart. HTTP has no builtin resume for uploads. You could use the Content-Range header within POST or PUT requests but your server need to understand how to deal with this header. Or you could spread the upload over multiple requests which again needs special server side code to rebuild the original file at the server.

The overhead for both protocols is about the same and could be ignored for anything but very small files.

2) My Server is FTP storage repository, can I still use HTTP to upload without issue

If your server has no HTTP interface then you cannot use HTTP. But just the description of "FTP storage repository" does not give enough information about the ways it can be accessed.

3) Does FTP use multipart upload just like HTTP or how is network issues handled when there is frequent breaks

If its broken you need to find out where to restart with the upload (check remote length) and then use REST command.

这篇关于哪种文件上传协议(FTP / HTTP)对于高度不可靠的移动网络是有利的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆