yiduwangkai / ganymed-ssh-2

Automatically exported from code.google.com/p/ganymed-ssh-2
Other
0 stars 0 forks source link

Uploading files to a write-only sftp server not possible #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Have an SFTP server up and running that only allows writing files, but not 
reading files (i.e., SSH_FXF_CREAT and SSH_FXF_WRITE is allowed, but not 
SSH_FXF_READ)
2. Open a connection using new SFTPv3Client(sshConnection);
3. Try to create a file using SFTPv3Client.createFile(fileName)

What is the expected output? What do you see instead?
 Expected: File gets created and can subsequently be written to.
 Actual: The following stacktrace:
 ch.ethz.ssh2.SFTPException: File not found (SSH_FX_NO_SUCH_FILE: A reference was made to a file which does not exist.)
at ch.ethz.ssh2.SFTPv3Client.openFile(SFTPv3Client.java:1198)
at ch.ethz.ssh2.SFTPv3Client.createFile(SFTPv3Client.java:1071)
at ch.ethz.ssh2.SFTPv3Client.createFile(SFTPv3Client.java:1052)

What version of the product are you using? On what operating system?
 ganymed-ssh2-build251beta1, java7, ubuntu linux

Please provide any additional information below.
 SFTPv3Client.createFile(String fileName, SFTPv3FileAttributes attr) opens a file as following:
  return openFile(fileName, 0x00000008 | 0x00000003, attr); // SSH_FXF_CREAT | SSH_FXF_READ | SSH_FXF_WRITE
 The flags to be used should be configurable, not hard-coded.

Original issue reported on code.google.com by stefan.t...@gmail.com on 11 Jan 2012 at 10:11

GoogleCodeExporter commented 8 years ago
I am facing the same problem here..
with the change 
openFile(fileName, 0x00000008 | 0x00000002, attr); // SSH_FXF_CREAT | 
SSH_FXF_WRITE
I could create the file on the server.
Why do you need 
openFile(fileName, 0x00000008 | 0x00000002 | 0x00000001, attr); // 
SSH_FXF_CREAT | SSH_FXF_READ | SSH_FXF_WRITE
to resume an upload? therefore we can use the openFileRW method.
Or if the Outputstream supports setmark?

Original comment by stift1...@gmail.com on 23 Nov 2012 at 10:49

GoogleCodeExporter commented 8 years ago
Do not use "createFile()", use "openFile(...)" instead, this allows you to set 
custom flags:

openFile(fileName, SFTPv3Client.SSH_FXF_CREAT | SFTPv3Client.SSH_FXF_WRITE)

Original comment by cleondris on 1 Aug 2013 at 1:42