My application is uploading the file from SD Card to the directory on FileZilla FTP Server. After running my appliaction it gives me exception which I am unable to resolve after so many searches.
here is the log cat output:
06-24 11:06:53.715: W/System.err(1304): java.io.IOException: SimpleFTP received an unknown response when connecting to the FTP server: 220-FileZilla Server version 0.9.41 beta
06-24 11:06:54.055: W/System.err(1304): at org.jibble.simpleftp.SimpleFTP.connect(SimpleFTP.java:74)
06-24 11:06:54.087: W/System.err(1304): at com.example.upload1.MainActivity$UploadVideo.doInBackground(MainActivity.java:63)
06-24 11:06:54.167: W/System.err(1304): at com.example.upload1.MainActivity$UploadVideo.doInBackground(MainActivity.java:1)
06-24 11:06:54.167: W/System.err(1304): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-24 11:06:54.167: W/System.err(1304): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-24 11:06:54.167: W/System.err(1304): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-24 11:06:54.167: W/System.err(1304): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-24 11:06:54.167: W/System.err(1304): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-24 11:06:54.403: W/System.err(1304): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-24 11:06:54.403: W/System.err(1304): at java.lang.Thread.run(Thread.java:856)
and this is my code for the MainActivity.java
import java.io.File;
import org.jibble.simpleftp.SimpleFTP;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
//import com.kpbird.ftpdemo.R;
public class MainActivity extends Activity implements OnClickListener {
//FTPClient client;
/********* work only for Dedicated IP ***********/
static final String FTP_HOST= "203.199.134.131";
/********* FTP USERNAME ***********/
static final String FTP_USER = "a_gupta";
/********* FTP PASSWORD ***********/
static final String FTP_PASS ="AditI123";
Button btn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(this);
}
public void onClick(View v) {
UploadFile async = new UploadFile();
async.execute();
}
class UploadFile extends AsyncTask<String, Integer, String> {
@Override
protected String doInBackground(String... params) {
// ftpClient=uploadingFilestoFtp();
try {
SimpleFTP ftp = new SimpleFTP();
ftp.connect(FTP_HOST, 21, FTP_USER, FTP_PASS);
ftp.bin();
// Change to a new working directory on the FTP server.
ftp.cwd("callrecording");
// Upload some files.
ftp.stor(new File(Environment.getExternalStorageDirectory().getParent() + "/invite_json.txt"));
// ftp.stor(new File("comicbot-latest.png"));
// You can also upload from an InputStream, e.g.
// ftp.stor(new FileInputStream(new File("test.png")),
// "test.png");
// ftp.stor(someSocket.getInputStream(), "blah.dat");
// Quit from the FTP server.
ftp.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// dialog.show();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
Toast.makeText(MainActivity.this, "sent", Toast.LENGTH_LONG).show();
}
}
After running my appliaction
? Do you mean:while executing my AsyncTask
? FTPClient cannot connect is unclear. The complaint is about the response. And a response can only be there after connection... What do you mean withwork only for Dedicated IP
? Does the server accept only trusted client ip's? Which lines of your code get executed? Add Log.d() startements to find out. – Gilgaiwe need to define the IP in the FTP_HOST,
do you mean:static final String FTP_HOST= "203.199.134.131";
? – Gilgai