我们正在进行一些手工处理,以便从FileZilla下载并上载到远程SFTP服务器。对于客户端软件,我们没有任何权限问题。
最近,我们决定使用VB.NET将其移到预定的函数中,下载工作进行得很好(因此,为了使代码示例简洁,我将其从代码中删除)。
但是对于上传,程序遇到了一个错误:
WinSCP.SessionRemoteException:“无法创建远程文件”/某些路径/on/myFile.txt.filePart“。 拒绝许可。 错误代码:3 来自服务器(En)的错误消息:拒绝权限‘
下面是上传文件的代码。
Using session As New Session
session.Open(sessionOptions)
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
' localFilePath = "C:\somepath\myFile.txt"
If Not String.IsNullOrEmpty(localFilePath) And File.Exists(localFilePath) Then
transferResult = session.PutFiles(localFilePath, "/some path/on/remote/", False, transferOptions)
transferResult.Check() 'error was thrown here
Else
Throw New FileNotFoundException("The file could not be found")
End If
End Using
任何帮助都是非常感谢的,谢谢你的时间。
发布于 2020-03-12 19:24:21
使用SFTP协议,WinSCP默认情况下传输超过100 KB 通过临时文件的文件。如果您没有创建新文件的权限,这将无法工作。
在这种情况下,您需要通过临时文件(也就是可恢复的传输)禁用传输。对于那个集TransferOptions.ResumeSupport
Dim transferOptions As New TransferOptions
transferOptions.ResumeSupport.State = TransferResumeSupportState.Off
transferResult =
session.PutFiles(localFilePath, "/remote/path/", False, transferOptions)
transferResult.Check()
https://stackoverflow.com/questions/60550643
复制相似问题