Download Uri to file

This commit is contained in:
lionel
2021-03-05 11:36:19 +01:00
parent 4612b1a994
commit 54dce31f53
4 changed files with 6 additions and 8 deletions

View File

@ -277,7 +277,7 @@ public class Transfer {
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 Button button;
@ -286,8 +286,6 @@ public class Transfer {
else
button = null;*/
final File file = new File(uri.getPath());
URL url = null;
HttpURLConnection conn = null;
int maxBufferSize = 1 * 1024 * 1024;

View File

@ -302,13 +302,13 @@ public class DownloadFragment extends Fragment {
final String href = (String) layout.getTag(R.id.ID_FILE_HREF);
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();
new Thread(() -> {
try {
tr.downloadFile(uri, name, fileSize, href, button);
tr.downloadFile(file, name, fileSize, href, button);
} catch (IOException e) {
final String ExceptionName = e.getClass().getSimpleName();
final String ExceptionMess = e.getMessage();