cloud-agnostic-storage
Version:
A package which enables cloud agnostic storage for a NodeJS project.
43 lines (31 loc) • 1.23 kB
text/typescript
import CloudStorageService from "../services/CloudStorageService";
import cloudStorageRegistry from "./CloudStorageRegistry";
import { CloudStorageConstructor } from "../models/CloudStorageService.models";
import { CLOUD_PROVIDERS } from "../constants/CloudProviders";
var CloudStorageInstance: CloudStorageService;
function initializeCloudStorage(
CLOUD_PROVIDER_NAME: string = CLOUD_PROVIDERS.AZURE
): void {
const CloudStorage: CloudStorageConstructor =
cloudStorageRegistry.getCloudStorageClass(CLOUD_PROVIDER_NAME);
CloudStorageInstance = new CloudStorage();
return;
}
async function downloadFileAsync(keyName: string): Promise<string> {
const result = await CloudStorageInstance.downloadFileAsync("", "", "");
return result.message;
}
async function uploadFileAsync(keyName: string): Promise<string> {
const result = await CloudStorageInstance.uploadFileAsync("", "");
return result.message;
}
async function deleteFileAsync(keyName: string): Promise<string> {
const result = await CloudStorageInstance.deleteFileAsync("", "");
return result.message;
}
export {
initializeCloudStorage,
downloadFileAsync,
uploadFileAsync,
deleteFileAsync,
};