public abstract class SFBaseFileTransferAgent extends Object implements SnowflakeFixedView
Note that while SnowflakeFileTransferAgent is used liberally throughout the codebase for performing uploads, the "alternative" implementations may have quite different ways of uploading to cloud storage, so this is a rather "thin" abstract class that leaves much of the implementation up to the implementing class.
It is also expected that a command (GET/PUT) is parsed by the FileTransferAgent before either execute() or downloadStream() is called. This is not enforced by the abstract class's interface, but will be passed to the SFConnectionHandler's getFileTransferAgent().
In general, besides the abstract methods execute() and downloadStream(), an implementing class needs to also populate the statusRows List with the file-metadata rows forming the fixed view, as well as set the showEncryptionParameter boolean (usually returned by the session parameter; default is false).
| Modifier and Type | Class and Description |
|---|---|
static class |
SFBaseFileTransferAgent.CommandType
The types of file transfer: upload and download.
|
class |
SFBaseFileTransferAgent.DownloadCommandEncryptionFacade |
class |
SFBaseFileTransferAgent.DownloadCommandFacade
A class for encapsulating the columns to return for the download command
|
static class |
SFBaseFileTransferAgent.UploadColumns
A class for encapsulating the columns to return for the upload command
|
class |
SFBaseFileTransferAgent.UploadCommandEncryptionFacade |
class |
SFBaseFileTransferAgent.UploadCommandFacade |
| Modifier and Type | Field and Description |
|---|---|
protected SFBaseFileTransferAgent.CommandType |
commandType |
protected boolean |
compressSourceFromStream |
protected String |
destFileNameForStreamSource |
protected String |
destStagePath |
protected boolean |
showEncryptionParameter |
protected boolean |
sourceFromStream |
protected InputStream |
sourceStream |
protected List<Object> |
statusRows |
| Constructor and Description |
|---|
SFBaseFileTransferAgent() |
| Modifier and Type | Method and Description |
|---|---|
List<SnowflakeColumnMetadata> |
describeColumns(SFBaseSession session)
Describe the metadata of a fixed view.
|
abstract InputStream |
downloadStream(String fileName)
Download data from a stage.
|
abstract boolean |
execute()
Run the PUT/GET command, if a command has been set.
|
List<Object> |
getNextRow()
Move on to the next row of file metadata.
|
int |
getTotalRows()
Gets the total number of rows that this GET/PUT command's output returns in the fixed-view
result.
|
void |
setCompressSourceFromStream(boolean compressSourceFromStream)
Whether to compress the source stream before upload.
|
void |
setDestFileNameForStreamSource(String destFileNameForStreamSource)
Sets the target filename for uploading
|
void |
setDestStagePath(String destStagePath)
Sets the destination stage path
|
void |
setSourceStream(InputStream sourceStream)
Sets the source data stream to be uploaded.
|
protected boolean compressSourceFromStream
protected String destStagePath
protected String destFileNameForStreamSource
protected InputStream sourceStream
protected boolean sourceFromStream
protected boolean showEncryptionParameter
protected SFBaseFileTransferAgent.CommandType commandType
public int getTotalRows()
getTotalRows in interface SnowflakeFixedViewpublic List<Object> getNextRow() throws Exception
getNextRow in interface SnowflakeFixedViewExceptionpublic List<SnowflakeColumnMetadata> describeColumns(SFBaseSession session) throws Exception
describeColumns in interface SnowflakeFixedViewException - failed to construct listpublic void setSourceStream(InputStream sourceStream)
sourceStream - The source data to upload.public void setDestStagePath(String destStagePath)
destStagePath - The target destination stage path.public void setDestFileNameForStreamSource(String destFileNameForStreamSource)
destFileNameForStreamSource - The target destination filename once the file is uploaded.public void setCompressSourceFromStream(boolean compressSourceFromStream)
compressSourceFromStream - boolean for whether to compress the data stream before upload.public abstract boolean execute()
throws SQLException
SQLException - for SQL or upload errorspublic abstract InputStream downloadStream(String fileName) throws SnowflakeSQLException
fileName - A file on a stage to download.SnowflakeSQLException - If the file does not exist, or if an error occurred during
transport.Copyright © 2022. All rights reserved.