snowflake-sdk
Version:
Node.js driver for Snowflake
87 lines (86 loc) • 2.92 kB
TypeScript
/**
* Creates an S3 utility object.
*
* @param connectionConfig
*
* @param s3 - used for tests, mock can be supplied
* @returns {Object}
* @constructor
*/
export function S3Util(connectionConfig: any, s3: any): Object;
export class S3Util {
/**
* Creates an S3 utility object.
*
* @param connectionConfig
*
* @param s3 - used for tests, mock can be supplied
* @returns {Object}
* @constructor
*/
constructor(connectionConfig: any, s3: any);
/**
* Create an AWS S3 client using an AWS token.
*/
createClient: (stageInfo: any, useAccelerateEndpoint: any) => any;
/**
* Get file header based on file being uploaded or not.
*
* @param {Object} meta
* @param {String} filename
*
* @returns {Object}
*/
getFileHeader: (meta: Object, filename: string) => Object;
/**
* Create the file metadata then upload the file.
*
* @param {String} dataFile
* @param {Object} meta
* @param {Object} encryptionMetadata
*/
uploadFile: (dataFile: string, meta: Object, encryptionMetadata: Object) => Promise<void>;
/**
* Multipart upload of `dataFile` to S3, reading `MULTIPART_PART_SIZE_BYTES`
* bytes per chunk into a fresh Buffer and uploading each as a separate
* UploadPart call.
*
* On any error (token expiry, transient network failure, etc.), best-effort
* `AbortMultipartUpload` is issued so we don't leak partial-upload storage.
* The caller's existing retry semantics (RENEW_TOKEN / NEED_RETRY result
* statuses) layer cleanly on top: a failed upload leaves the stage clean
* for the retry to start over.
*
* @param {String} dataFile - Local file path to upload.
* @param {Number} fileSize - Pre-stat'd file size in bytes.
* @param {Object} meta
* @param {Object} encryptionMetadata
*/
uploadFileMultipart: (dataFile: string, fileSize: number, meta: Object, encryptionMetadata: Object) => Promise<void>;
/**
* Create the file metadata then upload the file stream.
*
* @param {Buffer|string|stream.Readable} fileStream
* @param {Object} meta
* @param {Object} encryptionMetadata
*/
uploadFileStream: (fileStream: Buffer | string | stream.Readable, meta: Object, encryptionMetadata: Object) => Promise<void>;
/**
* Download the file.
*
* @param {String} dataFile
* @param {Object} meta
* @param {Object} encryptionMetadata
*/
nativeDownloadFile: (meta: Object, fullDstPath: any) => Promise<void>;
}
export const SNOWFLAKE_S3_DESTINATION: "s3.amazonaws.com";
export const DATA_SIZE_THRESHOLD: 67108864;
/**
* Extract the bucket name and path from the metadata's stage location.
*
* @param {String} stageLocation
*
* @returns {Object}
*/
export function extractBucketNameAndPath(stageLocation: string): Object;