diff --git a/shared/js/FileManager.ts b/shared/js/FileManager.ts index dde1eec3..eb28f839 100644 --- a/shared/js/FileManager.ts +++ b/shared/js/FileManager.ts @@ -49,6 +49,12 @@ namespace transfer { request_file() : Promise; } + + export interface UploadTransfer { + put_data(data: BlobPart | File) : Promise; + + get_key(): transfer.UploadKey; + } export type DownloadKey = TransferKey; export type UploadKey = TransferKey; @@ -56,7 +62,7 @@ namespace transfer { export function spawn_download_transfer(key: DownloadKey) : DownloadTransfer { return new RequestFileDownload(key); } - export function spawn_upload_transfer(key: UploadKey) : RequestFileUpload { + export function spawn_upload_transfer(key: UploadKey) : UploadTransfer { return new RequestFileUpload(key); } } @@ -96,12 +102,16 @@ class RequestFileDownload implements transfer.DownloadTransfer { } } -class RequestFileUpload { +class RequestFileUpload implements transfer.UploadTransfer { readonly transfer_key: transfer.UploadKey; constructor(key: transfer.DownloadKey) { this.transfer_key = key; } + get_key(): transfer.UploadKey { + return this.transfer_key; + } + async put_data(data: BlobPart | File) : Promise { const form_data = new FormData();