Download Uri to file
This commit is contained in:
parent
4612b1a994
commit
54dce31f53
@ -277,7 +277,7 @@ public class Transfer {
|
|||||||
return fileList;
|
return fileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadFile(final Uri uri, String name, long fileSize, String href, Button button) throws IOException {
|
public void downloadFile(final File file, String name, long fileSize, String href, Button button) throws IOException {
|
||||||
|
|
||||||
/*final LinearLayout layout = activity.findViewById(id);
|
/*final LinearLayout layout = activity.findViewById(id);
|
||||||
final Button button;
|
final Button button;
|
||||||
@ -286,8 +286,6 @@ public class Transfer {
|
|||||||
else
|
else
|
||||||
button = null;*/
|
button = null;*/
|
||||||
|
|
||||||
final File file = new File(uri.getPath());
|
|
||||||
|
|
||||||
URL url = null;
|
URL url = null;
|
||||||
HttpURLConnection conn = null;
|
HttpURLConnection conn = null;
|
||||||
int maxBufferSize = 1 * 1024 * 1024;
|
int maxBufferSize = 1 * 1024 * 1024;
|
||||||
|
@ -302,13 +302,13 @@ public class DownloadFragment extends Fragment {
|
|||||||
final String href = (String) layout.getTag(R.id.ID_FILE_HREF);
|
final String href = (String) layout.getTag(R.id.ID_FILE_HREF);
|
||||||
|
|
||||||
new File(save_location).mkdirs();
|
new File(save_location).mkdirs();
|
||||||
Uri uri = Uri.fromFile(new File(save_location, name));
|
File file = new File(save_location, name);
|
||||||
|
|
||||||
Transfer tr = new Transfer();
|
Transfer tr = new Transfer();
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
tr.downloadFile(uri, name, fileSize, href, button);
|
tr.downloadFile(file, name, fileSize, href, button);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
final String ExceptionName = e.getClass().getSimpleName();
|
final String ExceptionName = e.getClass().getSimpleName();
|
||||||
final String ExceptionMess = e.getMessage();
|
final String ExceptionMess = e.getMessage();
|
||||||
|
@ -5,7 +5,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
classpath 'com.android.tools.build:gradle:4.1.2'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Mon Jan 11 18:53:24 CET 2021
|
#Thu Feb 18 20:04:28 CET 2021
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user