"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchCloudStorage = void 0;
/** @internal */
class FetchCloudStorage {
    async download(input) {
        if (input.transferType === "stream")
            throw new Error("Method not implemented.");
        if (this.isUrlInput(input)) {
            return (await fetch(input.url)).arrayBuffer();
        }
        if (!("authentication" in input.transferConfig))
            throw new Error("authentication missing in transferConfig");
        const url = `${input.transferConfig.baseUrl}/${this.buildObjectKey(input.reference)}?${input.transferConfig.authentication}`;
        const resp = await fetch(url);
        if (!resp.ok)
            throw new Error(resp.statusText);
        return resp.arrayBuffer();
    }
    buildObjectKey(ref) {
        const relative = ref.relativeDirectory ? `/${ref.relativeDirectory}` : "";
        return `${ref.baseDirectory}${relative}/${ref.objectName}`;
    }
    isUrlInput(input) {
        return "url" in input;
    }
    async upload(_input) {
        throw new Error("Method not implemented.");
    }
    async uploadInMultipleParts(_input) {
        throw new Error("Method not implemented.");
    }
}
exports.FetchCloudStorage = FetchCloudStorage;
//# sourceMappingURL=FetchCloudStorage.js.map