A random access storage compliant interface for SFTP files random access.
$ npm install random-access-sftpconst sftp = require('random-access-sftp')
cont file = sftp(`sftp://user:password@hostname:9000/path/to/file`)
file.open((err) => {
file.stat((err, stats) => {
file.write(0, Buffer.from('hello'), (err) => {
file.read(0, 5, console.log)
})
})
})Creates a random-access-storage interface to a SFTP file where
uri is a valid URL string or
WHATWG URL and
opts is an optional options object that is merged into the parsed URL()
object that uri is given to. In other words, uri can contain all of
the properties needed to create a SFTP connection and point to the file
that will be randomly accessed.
const file = sftp({
pathname: '/path/to/file',
host: 'example.com',
password: 'password',
username: 'alice',
port: 9000
})Or with a valid URL
const file = sftp('sftp://alice:[email protected]:9000/path/to/file')MIT