EasyFTP


Source link: https://github.com/linkindrew/easyFTP

EasyFTP

A Simple Wrapper Class for Apache-commons FTPClient to Easily Upload/Download Any kind of File over FTP. This Library is targeted for novice developers and providies very minimialistic and easily understandable Interface for FTP usage.

FEATURES :

  • Simple and Minimialistic with Default Configurations.
  • Totally Customizable (with provisional Access to Apache-commons FTPClient Methods).
  • Ideal for Novice Developers with no FTP background Knowledge and experiance.
  • Demo application Source Code Included.

Demo & Testing :

You can Download APK for testing. This Demo app. will upload a test.png image file on specified server and downloads specified file to your device for server.

You can use your public FTP Servers for testing like This one

USAGE :

All methods of library Throw Exceptions to be handeled in method-calling body. FTP operations should be performed in ASYNCTASK ( UI independent Thread ). Several use cases are discussed below :

Add this to your build.gradle dependenies of your module :

dependencies {

compile 'com.adeel:easyFTP:1.0'
  //...other dependencies  
}

Make sure that your top level build.gradle has JCenter() repo :

allprojects {

  repositories {

jcenter()

//...other repos.
  
}
 
}

Connecting to FTP Server :

Method :  
 public void connect(String Address, String userName, String password);
 //using Default port 21

Uploading to FTP Server :

Methods : 
 public void uploadFile(String uri);
 //By giving File Path of File existing on Device , to be uploaded.
OR 
 public void uploadFile(InputStream srcFileStream, String name);
  //By passing InputFileStream and

 //FileName.Extention
Example of Uploading some Resource Image (existing in res/drawable) 
 class uploadTask extends AsyncTask<String, Void, String> {

  @Override

protected String doInBackground(String... params) {

 try {

  easyFTP ftp = new easyFTP();

  ftp.connect("address","username","password");

  boolean status=false;

  status=ftp.setWorkingDirectory("Files/Uploads/Images");
 // if User say provided any Destination then Set it , otherwise

 // Upload will be stored on Default /root level on server

  InputStream is=getResources().openRawResource(+R.drawable.easyftptest);

  ftp.uploadFile(is,"test.png");

  return new String("Upload Successful");

 
}
catch (Exception e){

  String t="Failure : " + e.getLocalizedMessage();

  return t;

 
}

}

  
}

Downloading to From Server :

Methods : 
 public void downloadFile(String TargetFilePath, String destination);
Example of Downloading Image (existing on Files/Uploads) 
 class downloadTask extends AsyncTask<String, Void, String> {

  @Override

protected String doInBackground(String... params) {

 try {

  easyFTP ftp = new easyFTP();

  InputStream is=getResources().openRawResource(+R.drawable.easyftptest);

  ftp.connect("address","username","password");

  ftp.downloadFile( "Files/Uploads/test.png" , "downloaded_image.png" );

  return new String("Download Successful");

 
}
catch (Exception e){

  String t="Failure : " + e.getLocalizedMessage();

  return t;

 
}

  
}

Compression (Mode-Z) :

You can send a File in compress mode which can reduce size of certain files to speed up transfers. Read more about it

Other Methods :

 public void setFtpClient(FTPClient mFtpClient);

 // Set Your own Customized FTPClient
  public String [] listName ();

 // Returns List of Files in current working directory
  public boolean setWorkingDirectory (String dir);

// Sets Working Directory
  public FTPClient getFtpClient()

  // Returns Private member FTPClient, Apache-commons FTPClient operations

  // can be performed on this allowing complete customization.
  public void setTimeout (int seconds);

  // Sets Connection timout , default is 10 secs.
  public boolean makeDir(String dir);

 // Creates Directory on server at given path 
  public void disconnect();

  // Disconnects FTPClient

LICENSE

Copyright 2015-2016 ADEEL AHMAD Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

SimplePrefs is an Android library that helps working with SharedPreferences.

xpresso is a Java library inspired by Python. It allows a (near) line-into-line rewrite of a Python code into Java. It's also a great way to prototype your algorithms directly in Java.

Android ProgressBar that "bends" under its own weight.

This is an example project that uses Android Design Support Library.

PCollections serves as a persistent and immutable analogue of the Java Collections Framework. This includes efficient, thread-safe, generic, immutable, and persistent stacks, maps, vectors, sets, and bags, compatible with their Java Collections counterparts.

DeepLinkDispatch provides a declarative, annotation-based API to declare application deep links.

You can register an Activity to handle specific deep links by annotating it with @DeepLink and a URI. DeepLinkDispatch will parse the URI and dispatch the deep link to the appropriate Activity, along with any parameters specified in the URI.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes