Ganymed API를 사용하여 sftp를 유닉스 서버에 사용하고 있습니다. 서버에 파일을 만들 수 있지만 파일의 내용은 항상 비어 있습니다.Ganymed API : SFTP 사용
Ganymed의 API 위치 : http://www.ganymed.ethz.ch/ssh2/
코드 :
function (ByteArrayOutputStream reportBytes){
// reportBytes is a valid ByteArrayOutputStream
// if I write it to a file in to a local directory using reportBytes.writeTo(fout);
// I can see the contents */
byte byteArray[]=reportBytes.toByteArray();
SFTPv3FileHandle SFTPFILEHandle=sftpClient.createFileTruncate("test.txt");
//The file is created successfully and it is listed in unix
// The permissions of the file -rw-r--r-- 1 test.txt
sftpClient.write(SFTPFILEHandle, 0, byteArray, 0,byteArray.length);
//The above line doesnt seem to work, the file is always empty
}
/* write function definition is */
public void write(SFTPv3FileHandle handle, long fileOffset, byte[] src, int srcoff, int len) throws IOException
내가 당신의 문제를 해결하기 위해 노력
당신이 다른 SFTP 클라이언트와 그 테스트하여 서버에 파일을 업로드 할 수 있음을 확인 했 :) 방탄해야합니까? 어쩌면 귀하의 계정은 파일을 만들지 만 파일을 작성할 수있는 권한이 없습니다 ... – gutch