繁体   English   中英

FTP服务器应如何响应尝试检索不存在的文件

[英]How should FTP server respond to attempt to retrieve file that doesn't exist

我正在使用pyftplib创建用于上传视频的ftp服务器。 FTP服务器本身位于Google计算引擎的顶部,视频文件存储在Google云中。 我通过使用pyftplib中的事件回调将视频发送到ftp服务器时,将它们从计算引擎上载到云中来实现。 同样,当客户端请求文件时,我也会从Google Cloud中检索文件。 在下面的代码中描述的情况下,我需要回答未找到文件。 但是,我不清楚文件不存在时预期的FTP响应是什么。 我是否不知道特定的状态码?

def ftp_RETR(self, file):
    for restricted_file_name in restricted_file_names:
        if restricted_file_name.lower() in file.lower():
            self.respond('200') # this is where I want to say file doesn't exist
            return
    try:
        storage_client = storage.Client(project='myproject')
        bucket = storage_client.get_bucket('myvideo')
        blob = bucket.blob(file)
        blob.download_to_file(open(file, 'w'))
    except NotFound:
        pass
    FTPHandler.ftp_RETR(self, file)

谢谢

从RFC 959,即FTP标准:

 450 Requested file action not taken.
     File unavailable (e.g., file busy).

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM