# MAVSDK FTP: upload works, download/list fails

**URL:** <https://discuss.px4.io/t/mavsdk-ftp-upload-works-download-list-fails/27952>\
**Category:** MAVSDK\
**Created:** [June 17, 2022, 11:53am UTC](https://discuss.px4.io/t/mavsdk-ftp-upload-works-download-list-fails/27952 "2022-06-17T11:53:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rinto](https://discuss.px4.io/letter_avatar_proxy/v4/letter/r/b782af/32.png) [@rinto](https://discuss.px4.io/u/rinto)\
**Post date:** [June 17, 2022, 11:53am UTC](https://discuss.px4.io/t/mavsdk-ftp-upload-works-download-list-fails/27952/1 "2022-06-17T11:53:53Z")

</div>

Hey!

I’m have trouble with the ftp examples from MAVSDK.

I’m launching a mavlink ftp server from my companion pc, which is connected to the cube orange. The cube orange is connected to a Herelink remote control system.

I’m launching a mavlink ftp client from my second pc, which is connected to qgc on the Herelink ground unit via USB tethering.

I’m currently able to upload files, however I cannot download or list files. If I try this, I get a protocol error for dir, with a warning of an invalid path (while the path it prints is actually valid) and File does not exists for downloading a file, while the file does exist.

I did make sure that the permissions of the folder were set to read/write/execute for all groups on my pc.

Any possible fixes?

---

<div class="post-metadata">

**Author:** ![pablojr](https://discuss.px4.io/letter_avatar_proxy/v4/letter/p/7bcc69/32.png) [@pablojr](https://discuss.px4.io/u/pablojr)\
**Post date:** [June 19, 2022, 3:20pm UTC](https://discuss.px4.io/t/mavsdk-ftp-upload-works-download-list-fails/27952/2 "2022-06-19T15:20:53Z")

</div>

What if you try an FTP client from the same machine?  
This way you may rule out any issues with communication, and check that the FTP server works Ok.

---

<div class="post-metadata">

**Author:** ![rinto](https://discuss.px4.io/letter_avatar_proxy/v4/letter/r/b782af/32.png) [@rinto](https://discuss.px4.io/u/rinto)\
**Post date:** [June 20, 2022, 8:12am UTC](https://discuss.px4.io/t/mavsdk-ftp-upload-works-download-list-fails/27952/3 "2022-06-20T08:12:18Z")

</div>

thanks for your reply! I tried it with the client on the same computer, but I get the same error. Uploading works, downloading does not. Any other suggestions?

---

<div class="post-metadata">

**Author:** ![pablojr](https://discuss.px4.io/letter_avatar_proxy/v4/letter/p/7bcc69/32.png) [@pablojr](https://discuss.px4.io/u/pablojr)\
**Post date:** [June 20, 2022, 2:06pm UTC](https://discuss.px4.io/t/mavsdk-ftp-upload-works-download-list-fails/27952/4 "2022-06-20T14:06:12Z")

</div>

Ok. So it looks like your FTP server is not properly configured.

I’m not familiar with MAVSDK FTP examples, but from [documentation](https://mavlink.io/en/services/ftp.html#error_codes) you should receive a NAK with error code (i.e. UnkownCommand, FileNotFound, etc.)  
So what are the error code(s) you received?  
In addition, it would be great you mention on what OS you’re running the MAVSDK FTP server.

One more thing. You said upload works, but have you really confirmed that the file(s) you uploaded are actually written to disk on the proper location?

Pablo

---

<div class="post-metadata">

**Author:** ![rinto](https://discuss.px4.io/letter_avatar_proxy/v4/letter/r/b782af/32.png) [@rinto](https://discuss.px4.io/u/rinto)\
**Post date:** [June 20, 2022, 3:14pm UTC](https://discuss.px4.io/t/mavsdk-ftp-upload-works-download-list-fails/27952/5 "2022-06-20T15:14:31Z")

</div>

Hi!

I obtain the error “File does not exist” or “Protocol error” (see [class Ftp · MAVSDK Guide](https://mavsdk.mavlink.io/main/en/cpp/api_reference/classmavsdk_1_1_ftp.html) result section) for downloading and listing files respectively. In this issue I provided some outputs, if more outputs help I will defintely upload them! [File transfer MAVSDK: Protocol Error](https://discuss.px4.io/t/file-transfer-mavsdk-protocol-error/27917)

For the server I’m using stock ubuntu, but also tried on mac with the same results.

I confirmed the upload files are the correct files written to the expected location (folder of ftp\_server, from where I launch the server).

Thanks for your time and quick replies :)!

---

<div class="post-metadata">

**Author:** ![rinto](https://discuss.px4.io/letter_avatar_proxy/v4/letter/r/b782af/32.png) [@rinto](https://discuss.px4.io/u/rinto)\
**Post date:** [June 21, 2022, 8:42am UTC](https://discuss.px4.io/t/mavsdk-ftp-upload-works-download-list-fails/27952/6 "2022-06-21T08:42:12Z")

</div>

Okay, apparently it comes down to a bug in MAVSDK described here: [`set_root_directory()` does not set the root directory (FTP) · Issue #1766 · mavlink/MAVSDK · GitHub](https://github.com/mavlink/MAVSDK/issues/1766). Issue is marked as open, but a proposed solution for the server can be found in the comments:

````auto
while (true) {
    std::this_thread::sleep_for(std::chrono::seconds(1));

    for (auto system : mavsdk.systems()) { // Iterate through all available systems and call set_root_directory
        auto ftp_server = Ftp{system};
        ftp_server.set_root_directory("/home/ubuntu/ftp_test");
    }
}```
````
