Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
fix(application): download files with id
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelje authored and Hector Rondon committed Nov 23, 2017
1 parent 9adb8a3 commit db36d62
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/src/main/java/org/flyve/mdm/agent/utils/FilesHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class FilesHelper {
private static final String EXTERNAL_STORAGE = "EXTERNAL_STORAGE";
private Context context;
private Routes routes;
private String sessionToken;

/**
* This constructor loads the context of the current class
Expand Down Expand Up @@ -174,6 +175,7 @@ public Boolean downloadFile(String path, String id, String sessionToken) {
FlyveLog.e(ex.getMessage());
}

this.sessionToken = sessionToken;
final String url = routes.pluginFlyvemdmFile(id, sessionToken);
String completeFilePath = download(url, filePath);

Expand Down Expand Up @@ -202,6 +204,7 @@ public Boolean downloadApk(String packageFile, String id, String sessionToken) {
FlyveLog.e(ex.getMessage());
}

this.sessionToken = sessionToken;
final String url = routes.pluginFlyvemdmPackage(id, sessionToken);
String completeFilePath = download(url, filePath);
if(completeFilePath.equalsIgnoreCase("")) {
Expand Down Expand Up @@ -257,6 +260,9 @@ private String getFile(JSONObject jsonObjDownload, String path, String url, Stri
String fileName = "";

try {

String id = jsonObjDownload.getString("id");

// Both has name
if (jsonObjDownload.has("name")) {
fileName = jsonObjDownload.getString("name");
Expand All @@ -277,8 +283,8 @@ private String getFile(JSONObject jsonObjDownload, String path, String url, Stri
FlyveLog.d("File exists");
return "";
}

Boolean isSave = ConnectionHTTP.getSyncFile(url, filePath);
String urlLocal = routes.pluginFlyvemdmPackage(id, sessionToken);
Boolean isSave = ConnectionHTTP.getSyncFile(urlLocal, filePath);
if (isSave) {
Helpers.sendToNotificationBar(context, context.getResources().getString(R.string.download_file_ready));
FlyveLog.d("Download ready");
Expand Down

0 comments on commit db36d62

Please sign in to comment.