How to send data to FTP server?

It can be done using HTTP, but it’s messy. Is there any other possibility currently?

How much data are you trying to send? How often do you upload data? I’m assuming your sending to ftp so the data is stored and secured to ensure survival.

Let’s make up an example. 8 bytes every 30 seconds. It’s easy to do on Arduino and Wifly. I’d like to append it to 1 file. Can just keep it open using FTP commands?

http://www.cs.colostate.edu/helpdocs/ftp.html

Not too sure about that. Why not have the imp execute a http post every 30 sec to a particular website on server and/or on your own computer - apache web server (or even store a carbon copy on the agent - server:setpermanentvalues).

http://forums.electricimp.com/discussion/1225/event-log-to-file-on-web-server#Item_9

You can encode the bytes in the POST, or even in the url itself (req.query). For example,

https://agent.electricimp.com/myimpid/fileyouwishtosaveto?byte1=0xFF&byte2=0xFE…byte8=0xFD

This would work good for low amount of data being sent in a “slow” manner. Have the webpage use javascript or something decode the POST or req.query and re-build the data and save to file.

Yes, clearly using HTTP POST is the best way on the Imp’s end. How do I get that “small,slow” data to an FTP server? Do we really need 3 servers working together to do this? It’s so easy in the Arduino world. It talks directly to the FTP server with simple coding. I see 2 possible future solutions. An API in our Agent, or a web service that takes the URL, and sends it to a predefined FTP site. The FTP parameters can be stored in the URL itself. Then everyone can use it. It would work for 100’s at the same time since/if the data is so slow… Anyone want to work together to create this?

You really don’t need the three servers. The extra ones are just for redundancy, in case their servers “crash” or whatever. The FTP service really just parses information into a file hosted on a server. If you get a domain (I have three currently - $15/year), and have it hosted, you can have a webpage in your domain that receives this data and saves it to another file hosted on the same server, your domain web files.

Basically you use the webpage that is hosted to save the data within itself. Kinda the same thing a FTP service would do. Except without the FTP connection. You would use a FTP service normally to access/modify the files on that server. Just create a special web page (javascript, etc) to save instead of opening a FTP service. I will try and create a simple javascript page, host it on my domain and try asap!

But yes, having a web page that will push data through a FTP service (with the FTP parameters stored in the URL) would be super cool! I really don’t have the programming knowledge to extensively work with FTP and such.

http://forums.electricimp.com/discussion/comment/5856#Comment_5856

“The reason my answer was mostly No is that you can probably find a service somewhere online that you could send HTTP base64 encoded binary data and then download that data back over FTP”

Looks like this is the only way as of yet we could get the IMP to “implement” a FTP protocol. I’m sure the Electric Imp team will develop an API for this one day (hopefully)!

You are correct it does not have to be FTP at all. But it does have to be a file. I look forward to seeing your Simple solution! Simple is good, and the most important criteria of all!

It doesn’t matter to me what is the syntax of the URL, so long as it works with Agents. It doesn’t matter to me how you download or view the file, so long as it works with a PC easily. It would be great if there was flexibility without limiting the amount of data. Could be 2 bytes/hour. Or 16 bytes/sec. The overhead should not be 100x or ridiculous. I already have a server ready to go.

Looking forward to implementing your idea here!

Looks like we have to use PHP, not javascript.

http://php.net/manual/en/function.file-put-contents.php
http://stackoverflow.com/questions/4742898/write-post-data-to-file-with-php

Unfortunately I do not have much experience with PHP. However, I do have a few friends that do!

;))

And you can just use a standard ftp program to retrieve the file off the server when needed!

Your links above don’t seem to work when you click them.

So it’s only 1 line of code to do this? Don’t forget FILE_APPEND.

file_put_contents('test.txt', file_get_contents('php://input'));

From what I gather, yes. I hope!