On Fri, Nov 4, 2022 at 5:40 AM Jorge Lopez
<jorge.lo...@eu.equinix.com.invalid> wrote:

> Hi,
>
> I'm using my own development of guacamole server through a django project
> and I will like to specify and sftp path for drag and drop files upload. I
> tried with sftp-root-directory as specified in
> https://guacamole.apache.org/doc/gug/configuring-guacamole.html#ssh but I
> think it's just for file browser, because if a user drops a file in the
> window the file is upload to the user's home directory, not at the path
> specified in sftp-root-directory, and, in some cases this path doesn't
> exist so file is not uploaded or I can't find where the file is uploaded.
>

The "sftp-root-directory" parameter only affects the file browser. From the
documentation for that parameter:

"The directory to expose to connected users via Guacamole’s file browser.
If omitted, the root directory will be used by default."


Uploads that are just dragged into the browser window will go to whichever
path the SFTP server considers the default, typically the user's home
directory.

As I see in guacd container logs, there is no error and sftp is connected
> succesfully. With RDP connections 'drive_path' option is working as
> expected, but not for ssh. I also tried adding the absolute path to the
> filename once I created the FileStream in my .js client implementation:
>
> filename = `/tmp/test/${filename}`
>
> let stream = guac.createFileStream(mimetype, filename);
>
> But as I see in guacd logs, it's raising an error
>
> Filename "/tmp/test/test.docx" is invalid or resulting path is too long
>
>
The filename of a file stream is just the filename of the destination file,
not the destination path. The attempt to upload is being rejected because
of the inclusion of path separators in that filename. To upload to a
specific path, you'll need to use the same mechanism as the file browser,
leveraging the filesystem object received at the beginning of the
connection and then createOutputStream() of that filesystem object instead
of the client-level createFileStream(). For example:

// After setting a handler for guac.onfilesystem so we have a reference to
any received filesystem ...
let stream = filesystem.createOutputStream('application/octet-stream',
'/tmp/test/test.docx');


Unlike the file stream, the filesystem object has defined behavior for path
separators in stream names and will handle those as directories.

- Mike

Reply via email to