From 319be215465ba6d5f70c9e012a9a3347c90826f5 Mon Sep 17 00:00:00 2001 From: yimiao Date: Mon, 26 Jul 2021 17:45:32 +0800 Subject: [PATCH] =?UTF-8?q?author:wangyimiao=20desc:=E6=96=B0=E5=A2=9EFTP?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/commonlibtest/MainActivity.java | 15 ++ app/src/main/res/layout/activity_main.xml | 11 ++ build.gradle | 3 + commonLib/libs/commons-net-3.3.jar | Bin 0 -> 280983 bytes .../com/common/commonlib/utils/BaseUtils.kt | 8 ++ .../com/common/commonlib/utils/FTPUtils.kt | 133 ++++++++++++++++++ 6 files changed, 170 insertions(+) create mode 100644 commonLib/libs/commons-net-3.3.jar create mode 100644 commonLib/src/main/java/com/common/commonlib/utils/FTPUtils.kt diff --git a/app/src/main/java/com/common/commonlibtest/MainActivity.java b/app/src/main/java/com/common/commonlibtest/MainActivity.java index c681af4..ec323b0 100644 --- a/app/src/main/java/com/common/commonlibtest/MainActivity.java +++ b/app/src/main/java/com/common/commonlibtest/MainActivity.java @@ -11,6 +11,8 @@ import com.common.commonlib.image.loader.ImageLoader; import com.common.commonlib.net.RequestCallBack; import com.common.commonlib.net.interceptor.RequestHeadInterceptor; import com.common.commonlib.net.interceptor.ResponseHeadInterceptor; +import com.common.commonlib.utils.BaseUtils; +import com.common.commonlib.utils.FTPUtils; import com.common.commonlibtest.bean.ArticlesResponse; import com.common.commonlibtest.bean.CollectionResponse; import com.common.commonlibtest.bean.LoginResponse; @@ -118,5 +120,18 @@ public class MainActivity extends AppCompatActivity { } }); }); + + binding.uploadBtn.setOnClickListener(l -> { + String filePath = BaseUtils.INSTANCE.getExternalStorageDirectory(this); + String fileName = "/richang.md"; + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + FTPUtils.RESULT result = FTPUtils.INSTANCE.ftpUpload("192.168.101.215", "2221", "admin", "123456", filePath, fileName); + Log.i("wangym", result.name()); + } + }); + thread.start(); + }); } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 383b4a4..6f868b0 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -60,4 +60,15 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.770" /> +