From 453b6ea13844f8f79c33582efb0ff9db2d44ccdd Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Wed, 13 May 2026 17:17:16 +0800 Subject: [PATCH] fix: implement guacamole drive redirection file transfer --- src/backend/guacamole/routes.ts | 4 ++++ src/ui/features/guacamole/GuacamoleDisplay.tsx | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/backend/guacamole/routes.ts b/src/backend/guacamole/routes.ts index 84f8c2a6..f8874eb6 100644 --- a/src/backend/guacamole/routes.ts +++ b/src/backend/guacamole/routes.ts @@ -201,6 +201,10 @@ router.post( switch (connectionType) { case "rdp": + if (guacConfig["enable-drive"] && !guacConfig["drive-path"]) { + guacConfig["drive-path"] = "/drive"; + guacConfig["create-drive-path"] = true; + } token = tokenService.createRdpToken(hostname, username, password, { port: port || 3389, domain, diff --git a/src/ui/features/guacamole/GuacamoleDisplay.tsx b/src/ui/features/guacamole/GuacamoleDisplay.tsx index 09eebe90..bc0697fd 100644 --- a/src/ui/features/guacamole/GuacamoleDisplay.tsx +++ b/src/ui/features/guacamole/GuacamoleDisplay.tsx @@ -388,6 +388,20 @@ export const GuacamoleDisplay = forwardRef< Guacamole.AudioPlayer.getInstance(stream, mimetype); }; + client.onfile = (stream: Guacamole.InputStream, mimetype: string, filename: string) => { + const reader = new Guacamole.BlobReader(stream, mimetype); + reader.onend = () => { + const blob = reader.getBlob(); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = filename; + a.click(); + URL.revokeObjectURL(url); + }; + stream.sendAck("OK", Guacamole.Status.Code.SUCCESS); + }; + client.connect(); }, [ getWebSocketUrl,