2017-10-10 42 views
1

我正在使用pyftplib爲上傳視頻創建一個ftp服務器。 ftp服務器本身位於谷歌計算引擎之上,視頻文件存儲在谷歌雲中。 我這樣做是通過使用pyftplib中的事件回調來將視頻從計算引擎上傳到雲端,當它們被髮送到FTP服務器時。 同樣,我正在從客戶端請求時從Google雲中檢索文件。 在下面的代碼描述的情況下,我需要回應沒有找到文件。 但是,我不清楚文件不存在時期望的FTP響應是什麼。有沒有我不知道的特定狀態碼?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) 

謝謝

回答

2

從RFC 959,即FTP標準:

450 Requested file action not taken. 
    File unavailable (e.g., file busy). 
相關問題