Shop OBEX P1 Docs P2 Docs Learn Events
Fetch files from FTP server — Parallax Forums

Fetch files from FTP server

know_howknow_how Posts: 1
edited 2011-06-24 06:30 in Accessories
Hi all, anyone has any ideas how to fetch a file from an ftp server and save it onto the micro SD card? I've been studying the threads here and so far I only know that GET has something to do with it, but since I'm only a newbie much more than that is needed . Where can I find the complete code for such thing?
My project involves an MP3 player connected (through a microSD to USB adapter) to the spinneret, where the spinneret is supposed to download the mp3 files found on the server onto the mp3 player. Is this possible, and if so how can it be done?
Any help would be much appreciated,
Thanks.

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-06-24 06:30
    FTPing is like having a conversation with the FTP server.

    * Make a connection so you need the IP address
    * Send your credentials
    * Send the file transfer mode (ascii or binary)
    * Send the change directory command (cd /music)
    * Change directory on the SD card to where you want to put the file
    * Create/Open local file
    * Get and save the file size
    * Start file transfer (get)
    * Buffer the incoming stream in chunks decrementing from the file size
    * Save the buffered data
    * Stop when you have read all the bytes.

    You can find examples, not ftp but close, in the multi-socket project; http://www.agaverobotics.com/spinneret/source/ Take a look at the Firmware(id) method in the HTTPService object. Firmware(id) use a simple socket upload. The SMTP example in the snippets.spin file show how to establish a connection to a remote server and send messages.

    There are many how-to ftp guides on the Internet.
    http://www.davelozinski.com/tutorials/ftp/index.php?1308921640892
Sign In or Register to comment.