IPWorks SFTP 2020 Node.js Edition

Questions / Feedback?

SetAttributes Event

Fires when a client attempts to set file or directory attributes.

Syntax

sftpserver.on('SetAttributes', [callback])

Callback

The 'callback' is called when the 'SetAttributes' event is emited.

function(e){ }

The argument 'e' has the following properties:

e.connectionId
e.user
e.path
e.fileType
e.fileSize
e.fileOwner
e.fileGroup
e.filePermissions
e.fileATime
e.fileCreateTime
e.fileMTime
e.fileAttribBits
e.fileAttribBitsValid
e.otherAttributes
e.beforeExec
e.statusCode

Remarks

The SetAttributes event fires when an SFTP client sends an SSH_FXP_SETSTAT, SSH_FXP_FSETSTAT or SSH_FXP_FSTAT request. Path is the path of the file or directory the client wants to set attributes for.

This event is fired both before and after the attributes are set. The BeforeExec parameter is True before the operation has been executed and False otherwise. Handling this event before execution of the operation provides an opportunity to add custom logic that may prevent or deny the operation. Handling this event after execution of the operation provides an opportunity to report any errors that may have occurred during the operation.

File/Directory Attributes are specified using the following values:

FileType: The type of file. Can be one of the following values:

  • SSH_FILEXFER_TYPE_REGULAR (1)
  • SSH_FILEXFER_TYPE_DIRECTORY (2)
  • SSH_FILEXFER_TYPE_SYMLINK (3)
  • SSH_FILEXFER_TYPE_SPECIAL (4)
  • SSH_FILEXFER_TYPE_UNKNOWN (5)
  • SSH_FILEXFER_TYPE_SOCKET (6)
  • SSH_FILEXFER_TYPE_CHAR_DEVICE (7)
  • SSH_FILEXFER_TYPE_BLOCK_DEVICE (8)
  • SSH_FILEXFER_TYPE_FIFO (9)

FileSize: The file size, in bytes.

FileOwner: The file owner. If the ProtocolVersion configuration option is "3" (default), this field should be a numeric Unix-like user identifier. V4-V6 of the SFTP Protocol allow an arbitrary string.

FileGroup: The file owner group. If the ProtocolVersion configuration option is "3" (default), this field should be a numeric Unix-like group identifier. V4-V6 of the SFTP Protocol allow an arbitrary string.

FilePermissions: The POSIX-style file permissions.

FileATime: The file last-access time, in milliseconds since Jan 1, 1970 in UTC.

FileCreateTime: The file creation time, in milliseconds since Jan 1, 1970 in UTC.

FileMTime: The file last-modified time, in milliseconds since Jan 1, 1970 in UTC.

FileAttrBits: The file attributes, as a combination of the following values:

  • SSH_FILEXFER_ATTR_FLAGS_READONLY (0x00000001)
  • SSH_FILEXFER_ATTR_FLAGS_SYSTEM (0x00000002)
  • SSH_FILEXFER_ATTR_FLAGS_HIDDEN (0x00000004)
  • SSH_FILEXFER_ATTR_FLAGS_CASE_INSENSITIVE (0x00000008)
  • SSH_FILEXFER_ATTR_FLAGS_ARCHIVE (0x00000010)
  • SSH_FILEXFER_ATTR_FLAGS_ENCRYPTED (0x00000020)
  • SSH_FILEXFER_ATTR_FLAGS_COMPRESSED (0x00000040)
  • SSH_FILEXFER_ATTR_FLAGS_SPARSE (0x00000080)
  • SSH_FILEXFER_ATTR_FLAGS_APPEND_ONLY (0x00000100)
  • SSH_FILEXFER_ATTR_FLAGS_IMMUTABLE (0x00000200)
  • SSH_FILEXFER_ATTR_FLAGS_SYNC (0x00000400)
  • SSH_FILEXFER_ATTR_FLAGS_TRANSLATION_ERR (0x00000800)

FileAttrBitsValid: A mask specifying which bits in FileAttrBits are supported by the server.

OtherAttributes: A semi-colon (';') delimited list of Name=Value pairs of other attributes supported by SFTP. These include:

  • MIMEType (String)
  • AllocationSize (64-bit int)
  • ATimeNS (int): ATime nanoseconds
  • CreateTimeNS (int): CreateTime nanoseconds
  • MTimeNS (int): MTime nanoseconds
  • TextHint (8-bit int)
  • LinkCount (int)
  • UntranslatedName (String)

FileMimeType: The MIME type of the file.

Valid status codes are:

  • SSH_FX_OK 0
  • SSH_FX_EOF 1
  • SSH_FX_NO_SUCH_FILE 2
  • SSH_FX_PERMISSION_DENIED 3
  • SSH_FX_FAILURE 4
  • SSH_FX_BAD_MESSAGE 5
  • SSH_FX_NO_CONNECTION 6
  • SSH_FX_CONNECTION_LOST 7
  • SSH_FX_OP_UNSUPPORTED 8
  • SSH_FX_INVALID_HANDLE 9
  • SSH_FX_NO_SUCH_PATH 10
  • SSH_FX_FILE_ALREADY_EXISTS 11
  • SSH_FX_WRITE_PROTECT 12
  • SSH_FX_NO_MEDIA 13
  • SSH_FX_NO_SPACE_ON_FILESYSTEM 14
  • SSH_FX_QUOTA_EXCEEDED 15
  • SSH_FX_UNKNOWN_PRINCIPAL 16
  • SSH_FX_LOCK_CONFLICT 17
  • SSH_FX_DIR_NOT_EMPTY 18
  • SSH_FX_NOT_A_DIRECTORY 19
  • SSH_FX_INVALID_FILENAME 20
  • SSH_FX_LINK_LOOP 21
  • SSH_FX_CANNOT_DELETE 22
  • SSH_FX_INVALID_PARAMETER 23
  • SSH_FX_FILE_IS_A_DIRECTORY 24
  • SSH_FX_BYTE_RANGE_LOCK_CONFLICT 25
  • SSH_FX_BYTE_RANGE_LOCK_REFUSED 26
  • SSH_FX_DELETE_PENDING 27
  • SSH_FX_FILE_CORRUPT 28
  • SSH_FX_OWNER_INVALID 29
  • SSH_FX_GROUP_INVALID 30
  • SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK 31

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks SFTP 2020 Node.js Edition - Version 20.0 [Build 8263]