Author Topic: Collecting files from a remote FTP server and saving to SD card  (Read 5247 times)

Offline FAQ

  • Newbie
  • *
  • Posts: 27
    • View Profile
Collecting files from a remote FTP server and saving to SD card
« on: November 16, 2012, 04:52:48 PM »

I would like to receive files from a remote FTP server and save them to an SD card. I have seen that when I do this with the FTP client in the uTasker project the file's content is displayed on the debug interface - what needs to be done to save it to a file instead?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Collecting files from a remote FTP server and saving to SD card
« Reply #1 on: November 16, 2012, 04:54:29 PM »
Hi

The FTP Client receives data from the server and passes it to the application layer (in debug.c in the demo). What the application does with the data is defined by the application – the demo sends it to the debug output so that it can be seen and verified.

If you want to save the content to the SD card you will need to create a file (with the correct name) and then write the received data (best to do this in buffers of 512 bytes since it is the most efficient size for the SD card sector writes). When you have received the complete file you can save the last open buffer (usually less that 512 bytes) and close the file. That should be all that is needed.

Note that you can also test this in the simulator since it also simulated an SD card (although the simulation slows down with SD card simulated content size growth…).

After the download you can view the saved file to check its size and content.

Regards

Mark