イム:私が得た接続FTPS、ACTIVE、EXPLICITFTPS storeFile FTPSサーバーへ 接続方法ファイルを送信しようと常に偽のJava
setFileType(FTP.BINARY_FILE_TYPE);
setFileTransferMode(FTP.BLOCK_TRANSFER_MODE);
が右後の応答文字列をチェックする:
234 AUTH command ok. Expecting TLS Negotiation.
からhere
234 Specifies that the server accepts the authentication mechanism specified by the client, and the exchange of security data is complete. A higher level nonstandard code created by Microsoft.
f私は
は、私が得た右のストアファイルの後に応答文字列をチェックする偽取得storeFileまたはstoreUniqeFileとILE:501 Server cannot accept argument.
奇妙である私はmakeDirectory("test1");
で 何の問題もなく、このクライアントへのディレクトリを作成することができましたlink1、例えばlink2
は私がエラーを時間外に出たto use ftp.enterLocalPassiveMode(); before ftp.storeFile(destinationfile, in);
をしようとしていた:私は、このリンクの両方をしようとしていました。
解決方法を知っている人はいますか?私も問題が解決しなかったthisソリューションを試してみました
public static void main(String[] args) throws Exception {
FTPSProvider ftps = new FTPSProvider();
String json = "connection details";
DeliveryDetailsFTPS details = gson.fromJson(json, DeliveryDetailsFTPS .class);
File file = File.createTempFile("test", ".txt");
FileUtils.write(file, " some test", true);
try (FileInputStream stream = new FileInputStream(file)) {
ftps.sendInternal(ftps.getClient(details), details, stream, file.getName());
}
}
protected void sendInternal(FTPClient client, DeliveryDetailsFTPS details, InputStream stream, String filename) throws Exception {
try {
// release the enc
DeliveryDetailsFTPS ftpDetails = (DeliveryDetailsFTPS) details;
setClient(client, ftpDetails);
boolean isSaved = false;
try (BufferedInputStream bis = new BufferedInputStream(stream)) {
isSaved = client.storeFile(filename, bis);
}
client.makeDirectory("test1");
client.logout();
if (!isSaved) {
throw new IOException("Unable to upload file to FTP");
}
} catch (Exception ex) {
LOG.debug("Unable to send to FTP", ex);
throw ex;
} finally {
client.disconnect();
}
}
@Override
protected FTPClient getClient(DeliveryDetails details) {
return new FTPSClient(isImplicitSSL((DeliveryDetailsFTPS) details));
}
protected void setClient(FTPClient client, DeliveryDetailsFTPS details) throws Exception {
DeliveryDetailsFTPS ftpDetails = (DeliveryDetailsFTPS) details;
client.setConnectTimeout(100000);
client.setDefaultTimeout(10000 * 60 * 2);
client.setControlKeepAliveReplyTimeout(300);
client.setControlKeepAliveTimeout(300);
client.setDataTimeout(15000);
client.connect(ftpDetails.host, ftpDetails.port);
client.setBufferSize(1024 * 1024);
client.login(ftpDetails.username, ftpDetails.getSensitiveData());
client.setControlEncoding("UTF-8");
int code = client.getReplyCode();
if (code == 530) {
throw new IOException(client.getReplyString());
}
// Set binary file transfer
client.setFileType(FTP.BINARY_FILE_TYPE);
client.setFileTransferMode(FTP.BLOCK_TRANSFER_MODE);
if (ftpDetails.ftpMode == FtpMode.PASSIVE) {
client.enterLocalPassiveMode();
}
client.changeWorkingDirectory(ftpDetails.path);
}
:
彼らは唯一の方法私ができ、送信ファイルだったがFileZillaのであり、それはFTPESを使用しています。 しかし、私はそれを行うために私のJavaコードが必要です。誰かが私に私はほとんど試してみましたさまざまなウェブサイト上で提供されるすべての可能な解決策は、それがApacheのFTPSクライアントで動作させることができませんでした
私たちは、このためにMCVEが必要だと思います。 234応答コードは、TLSネゴシエーションが行われていないと言い、コードを見て理由を理解するためにコードを実行する必要があることを確認します。 –
これについて説明します:http://stackoverflow.com/help/mcve –