com.snowflake.client.jdbc

## Class SnowflakeS3Client

- java.lang.Object
- - com.snowflake.client.jdbc.SnowflakeS3Client

    public class SnowflakeS3Client
    extends Object

Wrapper around AmazonS3Client.

Author:
  ffunke

### Constructor Summary

Constructors
Constructor and Description
`SnowflakeS3Client(com.amazonaws.auth.AWSCredentials awsCredentials, com.amazonaws.ClientConfiguration clientConfig, com.snowflake.gscommon.core.S3FileEncryptionMaterial encMat)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static void` `download(SnowflakeS3Client client, SFSession connection, String command, String localLocation, String destFileName, int parallelism, String bucketName, String stageFilePath)` Download a file from S3.
`int` `getEncryptionKeySize()`
`com.amazonaws.services.s3.model.ObjectMetadata` `getObjectMetadata(String bucketName, String prefix)`
`boolean` `isEncrypting()`
`com.amazonaws.services.s3.model.ObjectListing` `listObjects(String bucketName, String prefix)`
`void` `shutdown()`
`static void` `upload(SnowflakeS3Client client, SFSession connection, String command, int parallelism, int maxRetries, boolean uploadFromStream, String bucketName, File srcFile, String destFileName, InputStream inputStream, FileBackedOutputStream fileBackedOutputStream, com.amazonaws.services.s3.model.ObjectMetadata meta)` Upload a file (-stream) to S3.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SnowflakeS3Client

    public SnowflakeS3Client(com.amazonaws.auth.AWSCredentials awsCredentials,
                             com.amazonaws.ClientConfiguration clientConfig,
                             com.snowflake.gscommon.core.S3FileEncryptionMaterial encMat)
                      throws SnowflakeSQLException

Throws:
  `SnowflakeSQLException`

### Method Detail

#### isEncrypting

    public boolean isEncrypting()

#### getEncryptionKeySize

    public int getEncryptionKeySize()

#### shutdown

    public void shutdown()

#### listObjects

    public com.amazonaws.services.s3.model.ObjectListing listObjects(String bucketName,
                                                                     String prefix)
                                                              throws com.amazonaws.AmazonClientException,
                                                                     com.amazonaws.AmazonServiceException

Throws:
  `com.amazonaws.AmazonClientException`
  `com.amazonaws.AmazonServiceException`

#### getObjectMetadata

    public com.amazonaws.services.s3.model.ObjectMetadata getObjectMetadata(String bucketName,
                                                                            String prefix)
                                                                     throws com.amazonaws.AmazonClientException,
                                                                            com.amazonaws.AmazonServiceException

Throws:
  `com.amazonaws.AmazonClientException`
  `com.amazonaws.AmazonServiceException`

#### download

    public static void download(SnowflakeS3Client client,
                                SFSession connection,
                                String command,
                                String localLocation,
                                String destFileName,
                                int parallelism,
                                String bucketName,
                                String stageFilePath)
                         throws SnowflakeSQLException

Download a file from S3.

Parameters:
  `client` - s3 client instance
  `connection` - connection object
  `command` - command to download file
  `localLocation` - local file path
  `destFileName` - destination file name
  `parallelism` - number of threads for parallel downloading
  `bucketName` - s3 bucket name
  `stageFilePath` - stage file path
Throws:
  `SnowflakeSQLException` - if download failed without an exception
  `SnowflakeSQLException` - if failed to decrypt downloaded file
  `SnowflakeSQLException` - if file metadata is incomplete

#### upload

    public static void upload(SnowflakeS3Client client,
                              SFSession connection,
                              String command,
                              int parallelism,
                              int maxRetries,
                              boolean uploadFromStream,
                              String bucketName,
                              File srcFile,
                              String destFileName,
                              InputStream inputStream,
                              FileBackedOutputStream fileBackedOutputStream,
                              com.amazonaws.services.s3.model.ObjectMetadata meta)
                       throws SnowflakeSQLException

Upload a file (-stream) to S3.

Parameters:
  `client` - client object used to communicate with s3
  `connection` - connection object
  `command` - upload command
  `parallelism` - number of threads do parallel uploading
  `maxRetries` - max number of retries if upload failed
  `uploadFromStream` - true if upload source is stream
  `bucketName` - s3 bucket name
  `srcFile` - source file if not uploading from a stream
  `destFileName` - file name on s3 after upload
  `inputStream` - stream used for uploading if fileBackedOutputStream is null
  `fileBackedOutputStream` - stream used for uploading if not null
  `meta` - object meta data
Throws:
  `SnowflakeSQLException` - if upload failed even after retry