2015-11-27 44 views
0

A REST API有一個用於從.csv文件讀取的方法,該文件存在於URL上並聲稱此URL可以是公用地址或FTP服務器。作爲REST方法參數的我的FTP服務器的URL

我已經成功地將文件上傳到FTP服務器,但這不是我的問題。我想知道的是,如果我的文件已經上傳到FTPS服務器具有以下屬性

Host: 111.222.333.444 
Port: XX 
Username: myUserName 
Password: myPassword 
Working directory: /home/myFolder 
File name: myFile.csv 

如何將網址是什麼樣子?

API接受的URL當然是一個字符串值。我已經閱讀in this page,如果我寫的值爲

ftp://YourFtpUser%40YourDomain.com:[email protected] 

它會工作。但在這個地址中取代我的價值觀並不能讓我獲得任何地方。我將如何知道使用什麼格式?使用WinSCP來記錄文件。我取代了真實身份值。

. 2015-11-27 14:09:17.664 -------------------------------------------------------------------------- 
. 2015-11-27 14:09:17.664 WinSCP Version 5.7.6 (Build 5874) (OS 6.1.7601 Service Pack 1 - Windows 7 Enterprise) 
. 2015-11-27 14:09:17.664 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\ 
. 2015-11-27 14:09:17.665 Log level: Normal 
. 2015-11-27 14:09:17.665 Local account: ACTIONBASE\pedram.mobedi 
. 2015-11-27 14:09:17.665 Working directory: C:\Program Files (x86)\WinSCP 
. 2015-11-27 14:09:17.665 Process ID: 15780 
. 2015-11-27 14:09:17.665 Command-line: winscp.exe "ftp://myUserName:[email protected]:22/" /log=C:\mylog.log 
. 2015-11-27 14:09:17.665 Time zone: Current: GMT+1, Standard: GMT+1 (W. Europe Standard Time), DST: GMT+2 (W. Europe Daylight Time), DST Start: 2015-03-29, DST End: 2015-10-25 
. 2015-11-27 14:09:17.665 Login time: den 27 november 2015 14:09:17 
. 2015-11-27 14:09:17.665 -------------------------------------------------------------------------- 
. 2015-11-27 14:09:17.665 Session name: [email protected] (Ad-Hoc site) 
. 2015-11-27 14:09:17.665 Host name: 111.222.333.444 (Port: 22) 
. 2015-11-27 14:09:17.665 User name: myUsername (Password: Yes, Key file: No) 
. 2015-11-27 14:09:17.665 Transfer Protocol: FTP 
. 2015-11-27 14:09:17.665 Ping type: C, Ping interval: 30 sec; Timeout: 15 sec 
. 2015-11-27 14:09:17.665 Disable Nagle: No 
. 2015-11-27 14:09:17.665 Proxy: none 
. 2015-11-27 14:09:17.665 Send buffer: 262144 
. 2015-11-27 14:09:17.665 UTF: 2 
. 2015-11-27 14:09:17.665 FTP: FTPS: None; Passive: Yes [Force IP: A]; MLSD: A [List all: A] 
. 2015-11-27 14:09:17.665 Local directory: default, Remote directory: /home/myUsername/pedramtest/, Update: Yes, Cache: Yes 
. 2015-11-27 14:09:17.665 Cache directory changes: Yes, Permanent: Yes 
. 2015-11-27 14:09:17.665 Timezone offset: 0h 0m 
. 2015-11-27 14:09:17.665 -------------------------------------------------------------------------- 
. 2015-11-27 14:09:17.734 Connecting to 111.222.333.444:22 ... 
. 2015-11-27 14:09:17.734 Connected with 111.222.333.444:22. Waiting for welcome message... 
< 2015-11-27 14:09:17.734 SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2 
. 2015-11-27 14:09:32.870 Timeout detected. (control connection) 
. 2015-11-27 14:09:32.870 Connection failed. 
* 2015-11-27 14:09:32.901 (EFatal) Connection failed. 
* 2015-11-27 14:09:32.901 Timeout detected. (control connection) 
* 2015-11-27 14:09:32.901 Connection failed. 
+0

* 「沒有得到我的任何地方。」 *意味着什麼?任何錯誤消息? –

+0

@MartinPrikryl我的瀏覽器卡在「等待111.222.333.444」循環中。 – Disasterkid

回答

1

我們不知道您的REST API,所以我們無法知道它支持的格式。


總之,假設API遵循標準(RFC 1738)的URL格式是:

ftp://myUserName:[email protected]:XX/home/myFolder/myFile.csv 

據我所知,有對FTPS沒有標準。雖然ftps://通常用於通過隱式TLS/SSL連接的FTP。很少有客戶支持ftpes://以獲得明確的TLS/SSL。

如果端口號是21(或隱含的TLS/SSL爲990),則可以省略:XX


關於你試圖用的WinSCP:

  1. 您使用ftp://,而不是ftps://,所以很明顯非加密的FTP連接嘗試。
  2. 無論如何,服務器既不是FTP也不是FTPS,而是SFTP(SSH)。您可以通過「SSH-2.0-OpenSSH_6.0p1 Debian-4 + deb7u2」橫幅來告訴它,而不是FTP歡迎消息。 SFTP是與FTPS完全不同的協議。
    Differences between SFTP and "FTP over SSH"
    Is "SFTP" and "Ftp over SSL" a same thing?
+0

看起來不錯!但是,我不能使用我的瀏覽器(使用您提供的格式)下載文件嗎? – Disasterkid

+0

一般來說,你應該。如果您不是,請嘗試使用一些FTP客戶端進行日誌記錄並向我們顯示日誌。例如使用[WinSCP](http://winscp.net),你可以執行'winscp.exe ftps://用戶名:密碼@主機名/主目錄/ myFolder/myFile.csv/log = c:\ path \ ftp。日誌' –

+0

我使用WinSCP得到「超時檢測(控制連接)」。有沒有辦法可以提到這實際上是使用SSL的FTP?因爲我在日誌中看到了這一行:'FTP:FTPS:None;被動:是[強制IP:A]; MLSD:A [全部列出:A]'。 – Disasterkid

相關問題