FileLocationHandler::FileLocationHandlerSftp Class Reference

The class for handling file locations. More...

Inheritance diagram for FileLocationHandler::FileLocationHandlerSftp:
[legend]

## Public Attributes

const | SftpClientLocationOpts
| Valid SFTP location options. More...

## Protected Member Functions

binary | getBinaryFileImpl (string scheme, string location, *hash< auto > opts)
| Retrieves a binary file from the given location. More...
Qore::InputStream | getBinaryStreamImpl (string scheme, string location, *hash< auto > opts)
| Retrieves a binary file from the given location. More...
OutputStreamWrapper | getOutputStreamImpl (string scheme, string location, *hash< auto > opts)
| Returns an output stream for writing data to the given location. More...
hash< string, hash< FileHandlerOptionInfo > > | getReadOptionsImpl ()
| Gets supported read options. More...
object | getSftpClient (string scheme, string location, *hash< auto > opts, reference< string > file)
| Returns an SFTP client for the given location.
Qore::StreamReader | getStreamReaderImpl (string scheme, string location, *hash< auto > opts)
| Returns a stream reader for the file's data at the given location. More...
string | getTextFileImpl (string scheme, string location, *hash< auto > opts)
| Retrieves a text file from the given location. More...
hash< string, hash< FileHandlerOptionInfo > > | getWriteOptionsImpl ()
| Gets supported write options. More...
| writeFileImpl (string scheme, string location, data contents, *hash< auto > opts)
| Writes data to a file at the given location. More...

## Additional Inherited Members

Public Member Functions inherited from FileLocationHandler::AbstractFileLocationHandler
binary | getBinaryFile (string scheme, string location, *hash< auto > opts)
| Retrieves a binary file from the given location. More...
Qore::InputStream | getBinaryStream (string scheme, string location, *hash< auto > opts)
| Retrieves a binary file from the given location. More...
OutputStreamWrapper | getOutputStream (string scheme, string location, *hash< auto > opts)
| Returns an output stream for writing data to the given location. More...
hash< string, hash< FileHandlerOptionInfo > > | getReadOptions ()
| Gets supported read options. More...
Qore::StreamReader | getStreamReader (string scheme, string location, *hash< auto > opts)
| Returns a string stream for the file's data at the given location. More...
string | getTextFile (string scheme, string location, *hash< auto > opts)
| Retrieves a text file from the given location. More...
hash< string, hash< FileHandlerOptionInfo > > | getWriteOptions ()
| Gets supported write options. More...
| writeFile (string scheme, string location, data contents, *hash< auto > opts)
| Writes data to a file at the given location. More...
Static Protected Member Functions inherited from FileLocationHandler::AbstractFileLocationHandler
static string | forceEncoding (string str, *string encoding)
| Returns a string tagged with the given encoding, if any.

## Detailed Description

The class for handling file locations.

## Member Function Documentation

## getBinaryFileImpl()

binary FileLocationHandler::FileLocationHandlerSftp::getBinaryFileImpl | ( | string | scheme,
|  | string | location,
|  | *hash< auto > | opts
| ) |  |

protectedvirtual

Retrieves a binary file from the given location.

Parameters

  scheme | the scheme being used
  location | the location string without the scheme
  opts | read options

Returns
  the binary data of the file's contents, if it can be retrieved

Exceptions

  FILE-READ-ERROR | an I/O or other error occurred when reading the file

Implements FileLocationHandler::AbstractFileLocationHandler.

## getBinaryStreamImpl()

Qore::InputStream FileLocationHandler::FileLocationHandlerSftp::getBinaryStreamImpl | ( | string | scheme,
|  | string | location,
|  | *hash< auto > | opts
| ) |  |

protectedvirtual

Retrieves a binary file from the given location.

Parameters

  scheme | the scheme being used
  location | the location string without the scheme
  opts | read options

Returns
  an input stream of the file's contents, if it can be retrieved

Implements FileLocationHandler::AbstractFileLocationHandler.

## getOutputStreamImpl()

OutputStreamWrapper FileLocationHandler::FileLocationHandlerSftp::getOutputStreamImpl | ( | string | scheme,
|  | string | location,
|  | *hash< auto > | opts
| ) |  |

protectedvirtual

Returns an output stream for writing data to the given location.

Parameters

  scheme | the scheme being used
  location | the location string without the scheme
  opts | write options

Returns
  an output stream for writing to the file

Note
  - OutputStream::close() must be called to close the stream after writing terminates in order to avoid a deadlock
  - The data written to the OutputStreamWrapper object is written in the background; to ensure that the data has been written to the target, call OutputStreamWrapper::waitForIo()

Implements FileLocationHandler::AbstractFileLocationHandler.

## getReadOptionsImpl()

hash<string, hash<FileHandlerOptionInfo> > FileLocationHandler::FileLocationHandlerSftp::getReadOptionsImpl | ( |  | ) |

protectedvirtual

Gets supported read options.

Returns
  supported read options

Implements FileLocationHandler::AbstractFileLocationHandler.

## getStreamReaderImpl()

Qore::StreamReader FileLocationHandler::FileLocationHandlerSftp::getStreamReaderImpl | ( | string | scheme,
|  | string | location,
|  | *hash< auto > | opts
| ) |  |

protectedvirtual

Returns a stream reader for the file's data at the given location.

Parameters

  scheme | the scheme being used
  location | the location string without the scheme
  opts | read options

Returns
  a stream reader for the file's contents, if it can be retrieved

Implements FileLocationHandler::AbstractFileLocationHandler.

## getTextFileImpl()

string FileLocationHandler::FileLocationHandlerSftp::getTextFileImpl | ( | string | scheme,
|  | string | location,
|  | *hash< auto > | opts
| ) |  |

protectedvirtual

Retrieves a text file from the given location.

Parameters

  scheme | the scheme being used
  location | the location string without the scheme
  opts | read options

Returns
  the string of the file's contents, if it can be retrieved

Exceptions

  FILE-READ-ERROR | an I/O or other error occurred when reading the file

Implements FileLocationHandler::AbstractFileLocationHandler.

## getWriteOptionsImpl()

hash<string, hash<FileHandlerOptionInfo> > FileLocationHandler::FileLocationHandlerSftp::getWriteOptionsImpl | ( |  | ) |

protectedvirtual

Gets supported write options.

Returns
  supported write options

Implements FileLocationHandler::AbstractFileLocationHandler.

## writeFileImpl()

FileLocationHandler::FileLocationHandlerSftp::writeFileImpl | ( | string | scheme,
|  | string | location,
|  | data | contents,
|  | *hash< auto > | opts
| ) |  |

protectedvirtual

Writes data to a file at the given location.

Parameters

  scheme | the scheme being used
  location | the location string without the scheme
  contents | the file's contents
  opts | write options

Implements FileLocationHandler::AbstractFileLocationHandler.

## Member Data Documentation

## SftpClientLocationOpts

const FileLocationHandler::FileLocationHandlerSftp::SftpClientLocationOpts

Initial value:
= {
"encoding": <FileHandlerOptionInfo>{
"type": "string",
"desc": "file encoding (read / write)",
},
"ssh2_private_key": <FileHandlerOptionInfo>{
"type": "string",
"desc": "the private key file",
},
"ssh2_public_key": <FileHandlerOptionInfo>{
"type": "string",
"desc": "the public key file",
},
}

Valid SFTP location options.

supported options:

- `encoding:` the output string encoding for text files
- `ssh2_private_key:` the path to the private key file
- `ssh2_public_key:` the path to the public key file