简体   繁体   English

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

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

I'm using pyftplib to create an ftp server for uploading video. 我正在使用pyftplib创建用于上传视频的ftp服务器。 The ftp server itself sits on top of google compute engine with the video files being stored in google cloud. FTP服务器本身位于Google计算引擎的顶部,视频文件存储在Google云中。 I do this by using the event callbacks in pyftplib to upload the videos from compute engine to cloud when they are sent to the ftp server. 我通过使用pyftplib中的事件回调将视频发送到ftp服务器时,将它们从计算引擎上载到云中来实现。 Likewise I am retrieving the files from google cloud when they are requested by the client. 同样,当客户端请求文件时,我也会从Google Cloud中检索文件。 In the circumstance depicted in the code below I need to respond that a file is not found. 在下面的代码中描述的情况下,我需要回答未找到文件。 However, it is unclear to me what the expected FTP response is when a file does not exist. 但是,我不清楚文件不存在时预期的FTP响应是什么。 Is there a particular status code that I am unaware of? 我是否不知道特定的状态码?

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)

Thank you 谢谢

From RFC 959, ie the FTP standard: 从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