Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FTPClient ftp = new FTPClient();
- FileInputStream fis = null;
- String hash = Utils.getCRC32(file);
- ftp.connect("ip");
- ftp.setFileTransferMode(FTP.BINARY_FILE_TYPE);
- ftp.setFileType(FTP.BINARY_FILE_TYPE);
- ftp.enterLocalPassiveMode();
- ftp.login("username", "password");
- fis = new FileInputStream(file);
- int endIndex = file.getName().lastIndexOf(".");
- if (endIndex != -1){
- String fName = file.getName().substring(0, endIndex);
- String ext = file.getName().substring(endIndex, file.getName().length());
- String fileName = fName + "_" + hash + ext;
- Printer.log("Uploading " + fileName + "...");
- ftp.storeFile(fileName, fis);
- Printer.log("Successfully uploaded " + fileName + "!");
- }
- ftp.logout();
- ftp.disconnect();
- fis.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement