// Copyright © 2022-2026 Partium, Inc. DBA Partium import { ServiceProvider } from '../../service-provider'; import { BaseService } from '../../base.service'; import { Observable } from 'rxjs'; import { PFile } from '../../../models/p-file'; export declare enum TRANSFER_STATUS { TRANSFERRING = 0, TRANSFER_FINISHED = 1 } export type UploadStatus = { status: TRANSFER_STATUS; progress: number; }; export type DownloadStatus = { status: TRANSFER_STATUS; progress: number; file: PFile; }; /** * Service interface for providing primitive file upload and download functionality. * Based on the platform that is used, this service * needs to be implemented accordingly. * * An implementation of this service is required and has to be configured during * the initialization phase of Partium. * * This class file is called interface, even though it is not an interface, * but we need it to be a concrete class for the serviceProvider. */ export declare class FileTransferService extends BaseService { private readonly allowedDomains; constructor(serviceProvider: ServiceProvider, knownBaseUrls: string[]); protected validateIsKnownUrlOrCry(url: string): void; /** * Upload the given file to the given url and emit the upload status and progress during the * upload-process. * * Method should be overridden by child-class * * @param fileToUpload can be any PFile type that should be uploaded (depending on platform), * only the implementation of this interface needs to know how to deal with * the upload * @param uploadUrl the target upload url (must be publicly available without authentication) * @returns Observable that emits the UploadStatus */ uploadFile(fileToUpload: PFile, uploadUrl: string): Observable; /** * Download a file from the given url * * Method should be overridden by child-class * * @param url the download url (must be publicly available without authentication) * @returns Observable that emits the DownloadStatus and resolves with a PFile that wraps the * downloaded file in a platform-specific way */ downloadFile(url: string): Observable; }