From 1e5358df01545a3a88641532a35170e0dc5359e6 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Tue, 2 Apr 2024 11:31:38 +0200 Subject: [PATCH] feat: allow to specify the root of an upload Signed-off-by: skjnldsv --- lib/uploader.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/uploader.ts b/lib/uploader.ts index 6f886962..bcb8f440 100644 --- a/lib/uploader.ts +++ b/lib/uploader.ts @@ -167,9 +167,10 @@ export class Uploader { * Upload a file to the given path * @param {string} destinationPath the destination path relative to the root folder. e.g. /foo/bar.txt * @param {File} file the file to upload + * @param {string} root the root folder to upload to */ - upload(destinationPath: string, file: File): PCancelable { - const destinationFile = `${this.root}/${destinationPath.replace(/^\//, '')}` + upload(destinationPath: string, file: File, root?: string): PCancelable { + const destinationFile = `${root || this.root}/${destinationPath.replace(/^\//, '')}` // Get the encoded source url to this object for requests purposes const { origin } = new URL(destinationFile)