Skip to content
Advertisement

Read file extended attributes of files on SFTP server with JSch

I want to read file extended attributes using com.jcraft.JSch 0.1.55 (the file is on SFTP server). I know that class SftpATTR actually does have a method

JavaScript

but in my case it returns null.

I see that in this code

JavaScript

the last if-statement is responsible for reading extended attributes but it seems to me that it always evaluates to false, because

JavaScript

and

JavaScript

I cannot change the flags directly because it’s setter doesn’t have a public modifier.

Is there another way to change the flags or read the extended attributes somehow?

Advertisement

Answer

You seem to assume that the SFTP “extended attributes” are “file system extended attributes”.

They are not.

SFTP “extended attributes” is an extension mechanism, by which an SFTP server can provide or set additional attributes about the files, which are not part of the standard SFTP file attributes.

They indeed can theoretically be mapped to file system extended attributes. But actually most SFTP servers, and particularly the most widespread OpenSSH, do not support any SFTP extended attributes at all, let alone file system extended attributes. See also Setting the extended file attributes using SSH.NET SftpClient.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement