简体   繁体   中英

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. The ftp server itself sits on top of google compute engine with the video files being stored in google cloud. 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. Likewise I am retrieving the files from google cloud when they are requested by the client. 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. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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