Lecture 8 FTP into CS System Topics FTP

  • Slides: 12
Download presentation
Lecture 8: FTP into CS System Topics: FTP connect, browse, upload, download Date: Mar

Lecture 8: FTP into CS System Topics: FTP connect, browse, upload, download Date: Mar 8, 2016

Things to Learn (slide only) • FTP Overview • Using Anonymous FTP on UNC

Things to Learn (slide only) • FTP Overview • Using Anonymous FTP on UNC CS Systems • Android FTP Client API

FTP Overview • FTP stands for – File Transfer Protocol • Better than HTTP

FTP Overview • FTP stands for – File Transfer Protocol • Better than HTTP for uploading/downloading multiple large-sized files • It is a TCP based service • Separate ports for command (21) and data (20) • Data ports may be changed (in passive FTP) • Directory level control access (username/pass) • Less popular, less used, may die soon

FTP • Passive Mode FTP PASV PORT 2024 http: //www. slacksite. com/other/ftp. html

FTP • Passive Mode FTP PASV PORT 2024 http: //www. slacksite. com/other/ftp. html

SSH into UNC CS http: //cs. unc. edu/help-article/anonymous-ftp/ • The File System: To you:

SSH into UNC CS http: //cs. unc. edu/help-article/anonymous-ftp/ • The File System: To you: /afs/cs. unc. edu/home/ftp To your anonymous friend: / incoming you outgoing you Download Upload Your Anonymous Friend Will Access This As – • ftp. cs. unc. edu • Username = anonymous • Password = any email address

SSH into UNC CS • SSH Secure Shell Client • classroom. cs. unc. edu

SSH into UNC CS • SSH Secure Shell Client • classroom. cs. unc. edu • CS user/password • Useful Commands • • • pwd ls cd mkdir cat touch

Uploading Files • Uploading files from the phone to a server: • Using IP/TCP

Uploading Files • Uploading files from the phone to a server: • Using IP/TCP or IP/UDP Sockets • Using HTTP, HTTPS (GET, POST) • Using FTP, SFTP / incoming • • • ftp. cs. unc. edu Username = anonymous Password = any email address you

Android FTP API • Android does not have any! • Use 3 rd party

Android FTP API • Android does not have any! • Use 3 rd party Java API: Apache Commons Net Download: commons-net-3. 4. jar https: //commons. apache. org/proper/commons-net/ Add the jar to your Android studio project: https: //www. youtube. com/watch? v=tf. Pgx 6 c 5 wg. A

Using FTP API to Upload a File • Before uploading the file, first copy

Using FTP API to Upload a File • Before uploading the file, first copy a file into your phone’s SD card (use ADB or some App) Execute this on your computer’s command prompt: > adb push path/of/computer/file /sdcard/ The ADB tool can be found at, e. g. C: UsersYouApp. DataLocalAndroidSdkplatform-tools

Using FTP API to Upload a File • Write codes to connect and do

Using FTP API to Upload a File • Write codes to connect and do stuffs with files (e. g. change directory, browse files, upload) FTPClient ftp. Client = new FTPClient(); ftp. Client. connect(Inet. Address. get. By. Name("ftp. cs. unc. edu")); ftp. Client. login("anonymous", "xyz@cs. unc. edu"); ftp. Client. change. Working. Directory("incoming/nirjon"); FTPFile[] files = ftp. Client. list. Files(); ftp. Client. set. File. Type(FTP. BINARY_FILE_TYPE); Buffered. Input. Stream buff. In = null; File ff = new File("/sdcard/m. txt"); buff. In = new Buffered. Input. Stream(new File. Input. Stream(ff)); ftp. Client. enter. Local. Passive. Mode(); ftp. Client. store. File("upload 1. txt", buff. In); buff. In. close(); ftp. Client. logout(); ftp. Client. disconnect(); Tips – use permissions, use Async. Task

Using FTP API to Upload a File • Write codes to connect and do

Using FTP API to Upload a File • Write codes to connect and do stuffs with files (e. g. change directory, browse files, upload) FTPClient ftp. Client = new FTPClient(); ftp. Client. connect(Inet. Address. get. By. Name("ftp. cs. unc. edu")); ftp. Client. login("anonymous", "xyz@cs. unc. edu"); ftp. Client. change. Working. Directory("incoming/nirjon"); FTPFile[] files = ftp. Client. list. Files(); ftp. Client. set. File. Type(FTP. BINARY_FILE_TYPE); Buffered. Input. Stream buff. In = null; File ff = new File("/sdcard/m. txt"); buff. In = new Buffered. Input. Stream(new File. Input. Stream(ff)); ftp. Client. enter. Local. Passive. Mode(); ftp. Client. store. File("upload 1. txt", buff. In); buff. In. close(); ftp. Client. logout(); ftp. Client. disconnect(); Tips – use permissions, use Async. Task

Using FTP API to Upload a File • Write codes to connect and do

Using FTP API to Upload a File • Write codes to connect and do stuffs with files (e. g. change directory, browse files, upload) FTPClient ftp. Client = new FTPClient(); ftp. Client. connect(Inet. Address. get. By. Name("ftp. cs. unc. edu")); ftp. Client. login("anonymous", "xyz@cs. unc. edu"); ftp. Client. change. Working. Directory("incoming/nirjon"); FTPFile[] files = ftp. Client. list. Files(); ftp. Client. set. File. Type(FTP. BINARY_FILE_TYPE); Buffered. Input. Stream buff. In = null; File ff = new File("/sdcard/m. txt"); buff. In = new Buffered. Input. Stream(new File. Input. Stream(ff)); ftp. Client. enter. Local. Passive. Mode(); ftp. Client. store. File("upload 1. txt", buff. In); buff. In. close(); ftp. Client. logout(); ftp. Client. disconnect(); Tips – use permissions, use Async. Task