private void startDownload() { File downFolder = new File(getCacheDir(), getString(R.string.download_folder_path)); downFolder.mkdir(); File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path)); File fileToUpload = upFolder.listFiles()[0]; String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remotePath, downFolder.getAbsolutePath()); downloadOperation.addDatatransferProgressListener(this); downloadOperation.execute(mClient, this, mHandler); }
@Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result; /// download will be performed to a temporal file, then moved to the final location File tmpFile = new File(getTmpPath()); /// perform the download try { tmpFile.getParentFile().mkdirs(); result = downloadFile(client, tmpFile); Log_OC.i(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult<>(e); Log_OC.e(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + result.getLogMessage(), e); } return result; }