簡體   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