FTP协议中有什么像HTTP范围头? [英] Is there anything in the FTP protocol like the HTTP Range header?

查看:458
本文介绍了FTP协议中有什么像HTTP范围头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想通过FTP传输文件的一部分 - 是否可以使用标准的FTP协议?



在HTTP中,我可以使用范围标题中指定远程资源的数据范围。如果是1mb文件,我可以要求从600k到700k的字节。



FTP中有类似的东西吗?我正在阅读 FTP RFC ,没有看到任何东西,但想确保我'我不会错过任何东西。



FTP中有重新启动命令 - 是否可行?






附录

获取 REST 动词支持通过FTP读取资源的Seek()和Read()操作。

http://cheeso.members.winisp.net/srcview。 aspx?dir = streams& file = FtpReadStream.cs

Seek()很慢,因为设置数据套接字需要很长时间。当您将该流封装到 BufferedStream

解决方案

是的,您可以使用 REST 命令。



REST 设置后续文件传输开始的位置。它通常用于重新启动中断传输。命令必须在 RETR STOR 之前出现,因此在 PORT PASV



从FTP的RFC 959:


RESTART(REST)参数字段
表示要重新启动
文件传输的服务器标记。这个
命令不会导致文件传输
,而是跳过文件到
指定的数据检查点。这个
命令应该紧跟在
之后,通过相应的FTP服务命令
,这将导致文件传输到
resume。



了解更多:
http://www.faqs.org/rfcs/rfc959 .html#ixzz0jZp8azux



Suppose I want to transfer just a portion of a file over FTP - is it possible using a standard FTP protocol?

In HTTP I could use a Range header in the request to specify the data range of the remote resource. If it's a 1mb file, I could ask for the bytes from 600k to 700k.

Is there anything like that in FTP? I am reading the FTP RFC, don't see anything, but want to make sure I'm not missing anything.

There's a Restart command in FTP - would that work?


Addendum
After getting Brian Bondy's answer below, I wrote a read-only Stream class that wraps FTP. It supports Seek() and Read() operations on a resource that is read via FTP, based on the REST verb.
Find it at http://cheeso.members.winisp.net/srcview.aspx?dir=streams&file=FtpReadStream.cs

It's pretty slow to Seek(), because setting up the data socket takes a long time. Best results come when you wrap that stream in a BufferedStream.

解决方案

Yes you can use the REST command.

REST sets the point at which a subsequent file transfer should start. It is used usually for restarting interrupted transfers. The command must come right before a RETR or STOR and so come after a PORT or PASV.

From FTP's RFC 959:

RESTART (REST) The argument field represents the server marker at which file transfer is to be restarted. This command does not cause file transfer but skips over the file to the specified data checkpoint. This command shall be immediately followed by the appropriate FTP service command which shall cause file transfer to resume.

Read more: http://www.faqs.org/rfcs/rfc959.html#ixzz0jZp8azux

这篇关于FTP协议中有什么像HTTP范围头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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