Page 1 of 2

Intent to upload file(s)

Posted: Mon Apr 05, 2010 7:38 pm
by support
You can call AndFTP intent to upload file(s) from SDCard to FTP server:

Code: Select all

Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
// FTP URL (Starts with ftp://, sftp:// or ftps:// followed by hostname and port).
Uri ftpUri = Uri.parse("ftp://yourftpserver.com:21");
intent.setDataAndType(ftpUri, "vnd.android.cursor.dir/lysesoft.andftp.uri");
// FTP credentials (optional)
intent.putExtra("ftp_username", "anonymous");
intent.putExtra("ftp_password", "something@somewhere.com");
//intent.putExtra("ftp_keyfile", "/sdcard/dsakey.txt");
//intent.putExtra("ftp_keypass", "optionalkeypassword");
// FTP settings (optional)
intent.putExtra("ftp_pasv", "true");
//intent.putExtra("ftp_resume", "true");
//intent.putExtra("ftp_encoding", "UTF8");
// Upload
intent.putExtra("command_type", "upload");
// Activity title
intent.putExtra("progress_title", "Uploading files ...");
intent.putExtra("local_file1", "/sdcard/subfolder1/file1.zip");
intent.putExtra("local_file2", "/sdcard/subfolder2/file2.zip");
// Optional initial remote folder (it must exist before upload)
intent.putExtra("remote_folder", "remotefolder/subfolder");
startActivityForResult(intent, 1);
It will open the upload dialog where you can cancel upload if you need.
Upload files
Upload files
intent_upload_files.png (21.72 KiB) Viewed 35634 times

Re: Intent to upload file(s)

Posted: Mon Apr 19, 2010 9:55 pm
by brian
Is there any possibility that
onActivityResult(int requestCode, int resultCode, Intent data)
can be called with resultCode or data?
At this time I have no way of knowing if the xfer(upload) worked?
Thanks for a great product
-Brian

Re: Intent to upload file(s)

Posted: Mon Apr 26, 2010 8:08 pm
by support
We will see how to add a status code.

Re: Intent to upload file(s) - return code

Posted: Tue May 18, 2010 7:58 pm
by support
Status codes added in 1.5

- "close_ui" support added to Intent to close Activity after transfer.
- TRANSFERSTATUS string available in returned Intent
Values can be: UNKNOWN, COMPLETED, FAILED, CANCELLED.

Sample at the bottom of homepage: http://www.lysesoft.com/products/andftp/index.html

Re: Intent to upload file(s)

Posted: Wed Jun 09, 2010 7:00 pm
by raviteja
I am getting activitynotfound exception. Am i missing anything. Please help.

-r

Re: Intent to upload file(s)

Posted: Fri Jun 11, 2010 7:41 pm
by support
You may try to specify class name: "lysesoft.andftp.PickFTPTransferActivity" and make sure AndFTP 1.5 or 1.6 is installed.

Re: Intent to upload file(s)

Posted: Sun Jul 11, 2010 5:36 am
by raviteja
I am using the follwoing code but still i am getting Activiyty not found exception. Am i missing anything. I've Andftp 1.6 installed on my nexus one.

Any ideas ?


try{

Intent intnt = new Intent("lysesoft.andftp.PickFTPTransferActivity");
//intnt.setClassName("lysesoft.andftp", "PickFTPTransferActivity");
intnt.setAction( Intent.ACTION_PICK);

Uri ftpUri = Uri.parse("ftp://127.0.0.1");
intnt.putExtra("ftp_username", "demo");
intnt.putExtra("ftp_password", "demo");
intnt.putExtra("ftp_pasv", "true");
intnt.putExtra("command_type", "upload");
intnt.putExtra("progress_title", "Uploading files ...");
intnt.putExtra("/sdcard/1.3gp", "ravi.3gp");
startActivityForResult(intnt, 0);
}
catch(Exception ex)
{
Toast.makeText(ActivityRS.this, ex.toString(),Toast.LENGTH_LONG).show();
}

Re: Intent to upload file(s)

Posted: Mon Jul 12, 2010 9:21 pm
by Droidster
If anyone has any ideas.. I've implemented this code, the FTP connection/handshake seems to happen without issue. However, I am seeing the activity showing the progress, but it's not giving uploading information back, all of the activity's defaults are staying set to their defaults (read: blank).

I'm not seeing any errors either.

I'm stumped.

Any ideas, anyone?

My code:

Code: Select all

				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_PICK);
				// FTP URL (Starts with ftp://, sftp:// or ftps:// followed by hostname and port).
				Uri ftpUri = Uri.parse("ftp://mysite.com:21");
				intent.setDataAndType(ftpUri, "vnd.android.cursor.dir/lysesoft.andftp.uri");
				// FTP credentials (optional)
				intent.putExtra("ftp_username", "username");
				intent.putExtra("ftp_password", "password");
				//intent.putExtra("ftp_keyfile", "/sdcard/dsakey.txt");
				//intent.putExtra("ftp_keypass", "optionalkeypassword");
				// FTP settings (optional)
				intent.putExtra("ftp_pasv", "true");
				//intent.putExtra("ftp_resume", "true");
				//intent.putExtra("ftp_encoding", "UTF8");
				// Upload
				intent.putExtra("command_type", "upload");
				// Activity title
				intent.putExtra("progress_title", "Uploading file ...");
				intent.putExtra("local_file", "/sdcard/myproject/test.zip");
				//intent.putExtra("local_file2", "/sdcard/subfolder2/file2.zip");
				// Optional initial remote folder (it must exist before upload)
				intent.putExtra("remote_folder", "/test/ftp/Android");
				startActivityForResult(intent, 1);
I tried uploading the same local on phone file to the same location on the FTP server through the UI in AndFTP and it works fine! I double checked each line, username, password, etc., all matches. yet in my Android 2.1 application this is just not working. Surely this is something simple I'm overlooking?

Re: Intent to upload file(s)

Posted: Tue Jul 13, 2010 8:41 pm
by Droidster
If anyone has gotten this to work can you please explain what issues you overcame to get this working. Time is against me on this one and I need to find a solution as soon as possible.

If you have a working example that would be most helpful.

Thanks.

Re: Intent to upload file(s)

Posted: Tue Jul 13, 2010 11:02 pm
by Droidster
Okay, so this did turn out to be a simple fix. I, for some unknown reason, had removed the "1" in the first argument for:

intent.putExtra("local_file1", "/sdcard/folder/files.zip");

I believe I thought at first I could change the name of that arguement, but I never changed it back when I was doing my testing. Ah, nothing like hours wasted on a simple to fix issue. At least my project is working properly and now I can go beyond my test code.