I am new to SFTP.
I am getting Renci.SshNet.Common.SftpPermissionDeniedException: 'Permission denied'
error while uploading an image to the SFTP location from asp.net core.
I have installed the WinSCP tool, and there I can see that particular SFTP folder doesn't have "write" permission. and I don't have the right to change the permission.
below is my code
public void UploadFileToSFTP(IFormFile requestFile)
{
using (var sftp = new SftpClient(host, username, password))
{
sftp.Connect();
if (sftp.IsConnected)
{
using (var uplfileStream = requestFile.OpenReadStream())
{
sftp.UploadFile(uplfileStream, "/folderpath/" requestFile.fileName, null);
}
}
sftp.Disconnect();
}
}
am I doing anything wrong in the code?
or just adding write permission to the folder will work here.
Thanks in advance!
CodePudding user response:
I am able to upload images to the SFTP server after getting "write" permission for the SFTP folder.