net.snowflake.client.jdbc.SFBaseFileTransferAgent Maven / Gradle / Ivy
/*
* Copyright (c) 2012-2021 Snowflake Computing Inc. All rights reserved.
*/
package net.snowflake.client.jdbc;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import net.snowflake.client.core.SFBaseSession;
import net.snowflake.common.util.ClassUtil;
/**
* Base class for file transfers: given a SnowflakeConnection, files may be uploaded or downloaded
* from/to an InputStream.
*
* 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).
*/
public abstract class SFBaseFileTransferAgent implements SnowflakeFixedView {
protected boolean compressSourceFromStream;
protected String destStagePath;
protected String destFileNameForStreamSource;
protected InputStream sourceStream;
protected boolean sourceFromStream;
protected boolean showEncryptionParameter;
protected List