/**
* This file is part of the @egodigital/egoose distribution.
* Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/)
*
* @egodigital/egoose is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 3.
*
* @egodigital/egoose is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
///
import * as azureStorage from 'azure-storage';
/**
* Options for an 'AzureStorageClient'.
*/
export interface AzureStorageClientOptions {
/**
* A custom function or string that provides the name of the underlying container.
* If not defined, 'AZURE_STORAGE_CONTAINER' environment variable is used.
*
* @return {string|Function} The result with the container name or the container name as string.
*/
blobContainerProvider?: string | (() => string | Promise);
/**
* A custom function, which detects a MIME type by a blob name / path,
*
* @param {string} path The blob path / name.
*
* @return {string|Promise} The result with the detected MIME type.
*/
blobContentTypeDetector?: (path: string) => string | Promise;
/**
* A custom function that provides the 'BlobService' instance to use.
* If not defined, default settings from environment are used.
*
* @return {azureStorage.BlobService|Promise} The result with the service instance.
*/
blobServiceProvider?: () => azureStorage.BlobService | Promise;
/**
* A custom function that resolves a full blob path.
*
* @param {string} path The input path.
*
* @return {string|Promise} The result with the full path.
*/
toFullBlobPath?: (path: string) => string | Promise;
/**
* A custom function that creates a unique blob name.
*
* @param {string} path The input path / name of the blob.
*
* @return {string|Promise} The result with a unique blob name / path.
*/
uniqueBlobNameCreator?: (path: string) => string | Promise;
}
/**
* An async Azure Storage client.
*/
export declare class AzureStorageClient {
readonly options?: AzureStorageClientOptions;
/**
* Initializes a new instance of that class.
*
* @param {AzureStorageClientOptions} [options] The custom options.
*/
constructor(options?: AzureStorageClientOptions);
/**
* Creates a new blob service instance, based on the underlying options.
*
* @return {Promise} The promise with the new instance.
*/
createBlobService(): Promise;
/**
* Creates a new instance from environment settings.
*
* @return {AzureStorageClient} The new instance.
*/
static fromEnvironment(): AzureStorageClient;
/**
* Tries to return information about a blob.
*
* @param {string} path The path / name of the blob to check.
*
* @return {Promise} The promise that contains the blob information or (false) if it does not exist.
*/
getBlobInfo(path: string): Promise;
private getContainer;
/**
* Loads a blob.
*
* @param {string} path The path / blob name.
*
* @return {Promise} The promises with the loaded data.
*/
loadBlob(path: string): Promise;
/**
* Saves / uploads a blob.
*
* @param {string} path The path / name of the blob.
* @param {any} data The data to upload / store.
*/
saveBlob(path: string, data: any): Promise;
/**
* Saves a blob with a unique name / path.
*
* @param {string} path The original path / name of the blob.
* @param {any} data The data to store / save.
*
* @return {Promise} The promise with the path / name of the stored blob.
*/
saveUniqueBlob(path: string, data: any): Promise;
private toFullPath;
}
/**
* Normalizes an Azure blob path.
*
* @param {string} p The input path.
*
* @return {string} The normalized path.
*/
export declare function normalizeAzureBlobPath(p: string): string;