/** @packageDocumentation * @module iModelHub */ /// import * as https from "https"; import { Transform, TransformCallback } from "stream"; import { AuthorizedClientRequestContext, CancelRequest, FileHandler, ProgressCallback } from "@bentley/itwin-client"; import { ConfigData } from "./BlobDownloader"; /** * Stream that buffers writing to file. * @internal */ export declare class BufferedStream extends Transform { private _buffer?; private _bufferPointer; private _bufferSize; constructor(bufferSize: number); private allocNewBuffer; /** * Transforms the data passing through the stream into buffers. * @param chunk The Buffer to be transformed. * @param encoding Encoding type of chunk if chunk is string. * @param callback A callback function (optionally with an error argument and data) to be called after the supplied chunk has been processed. */ _transform(chunk: any, encoding: string, callback: TransformCallback): void; /** * This will be called when there is no more written data to be consumed, but before the 'end' event is emitted signaling the end of the Readable stream. * @param callback A callback function (optionally with an error argument and data) to be called when remaining data has been flushed. */ _flush(callback: TransformCallback): void; } /** * Provides methods to work with the file system and azure storage. An instance of this class has to be provided to [[IModelClient]] for file upload/download methods to work. * @internal */ export declare class AzureFileHandler implements FileHandler { /** @internal */ agent?: https.Agent; private _threshold; private _useDownloadBuffer; private _config; /** * Constructor for AzureFileHandler. * @param useDownloadBuffer Should Buffering be used when downloading files. If undefined, buffering is enabled only for Azure File Shares mounted with a UNC path. * @param threshold Minimum chunk size in bytes for a single file write. */ constructor(useDownloadBuffer?: boolean, threshold?: number, config?: ConfigData); /** Check if using Azure File Share with UNC path. This is a temporary optimization for Design Review, until they move to using SSD disks. */ private useBufferedDownload; /** Create a directory, recursively setting up the path as necessary. */ private static makeDirectoryRecursive; private transferFileUsingAzCopy; private downloadFileUsingHttps; /** * Make url safe for logging by removing sensitive information * @param url input url that will be strip of search and query parameters and replace them by ... for security reason */ private static getSafeUrlForLogging; /** * Check if sas url has expired * @param download sas url for download * @param futureSeconds should be valid in future for given seconds. */ static isUrlExpired(downloadUrl: string, futureSeconds?: number): boolean; /** * Determine if azcopy should be used for file transfer * @param fileSize size of the transferred file in bytes */ private useAzCopyForFileTransfer; /** * Download a file from AzureBlobStorage for iModelHub. Creates the directory containing the file if necessary. If there is an error in the operation, incomplete file is deleted from disk. * @param requestContext The client request context * @param downloadUrl URL to download file from. * @param downloadToPathname Pathname to download the file to. * @param fileSize Size of the file that's being downloaded. * @param progressCallback Callback for tracking progress. * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) if one of the arguments is undefined or empty. * @throws [[ResponseError]] if the file cannot be downloaded. */ downloadFile(requestContext: AuthorizedClientRequestContext, downloadUrl: string, downloadToPathname: string, fileSize?: number, progressCallback?: ProgressCallback, cancelRequest?: CancelRequest): Promise; /** Get encoded block id from its number. */ private getBlockId; private uploadChunk; /** * Upload a file to AzureBlobStorage for iModelHub. * @param requestContext The client request context * @param uploadUrl URL to upload the file to. * @param uploadFromPathname Pathname to upload the file from. * @param progressCallback Callback for tracking progress. * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) if one of the arguments is undefined or empty. * @throws [[ResponseError]] if the file cannot be uploaded. */ uploadFile(requestContext: AuthorizedClientRequestContext, uploadUrlString: string, uploadFromPathname: string, progressCallback?: ProgressCallback): Promise; private uploadFileUsingHttps; /** * Get size of a file. * @param filePath Path of the file. * @returns Size of the file. */ getFileSize(filePath: string): number; /** * Check if path is a directory. * @param filePath Path of the file. * @returns True if path is directory. */ isDirectory(filePath: string): boolean; /** * Check if path exists. * @param filePath Path of the file. * @returns True if path exists. */ exists(filePath: string): boolean; /** * Deletes file. * @param filePath Path of the file. */ unlink(filePath: string): void; /** * Get file name from the path. * @param filePath Path of the file. * @returns File name. */ basename(filePath: string): string; /** * Join multiple strings into a single path. * @param paths Strings to join. * @returns Joined path. */ join(...paths: string[]): string; } //# sourceMappingURL=AzureFileHandler.d.ts.map