I am trying to transfer a very small image (jpg) from an SD card to an FTP server using a Photon. I can see that the FTP server does accept the connection, however, its log file shows the following error:
@Jimmie, you defined data as a int which will read two bytes but only send one. You should define data as either a char or uint8_t. Try that to see if it works.
Thanks again @peekay123. I tried both but it did not work.
Sorry for wasting your time as I am realizing that the way I am doing it should not work. I am connecting to an FTP Server and then copying data to it without even telling it the name of the file to store it in.
When I tried using the ParticleFtpClient library, and using exact code like the example, I am getting the following error on open âno matching function for call to âparticleftpclient::ParticleFtpClient::open(String&, int&, int&)ââ
Also, the Web IDE goes wild and starts saying that it is missing .h files even though I checked that the Particle library is included along with its #include statement.
Is there anywhere a simple example that shows how to transfer a small jpg file from an SD card to an FTP server?
Do not use the built-in ParticleFtpClient library.
Import the ParticleFtpClient.cpp and ParticleFtpClient.h files
(I do not know how to attach cpp and h files but I copied those from the Particle FTPFileSender library)
Use this code in the body
#include "ParticleFtpClient.h"
#include <time.h>
using namespace particleftpclient;
String hostname = "server.dyndns.biz";
String username = "test";
String password = "test";
int port = 21;
int timeout = 5;
ParticleFtpClient ftp = ParticleFtpClient();
@ScruffR in the part of the send data code shown below:
while ((data = myFile.read()) >= 0) {
ftp.data.write(data);
}
[/quote]
This pulls data from the SD card in chunks as you already know, but canât we change this to pull the JPG image data chunks from the variable that holds the picture image thatâs created in your uCAM3 library?
I could try but I have no idea how it would or could work which is why I asked you.
Conceptually, it seems the only difference is where the bytes are being pulled from, the Data stored on an SD card vs Data stored in a variable in the Photons memory. But maybe itâs not that simple? No idea really.
So how is FTP different than the Server setup youâre talking about for @Vitesze ? Is it an FTP server or something different?
One âmajorâ difference Iâd anticipate is the timing with the rather slow uCam compared to an SD as source. This may or may not cause the FTP connection to time out and the code above does not take that into account (AFAICT).
The server I set up is running the NodeJS service and a rudimentary website to download the images.
I can PM you the details too.