From 88e184ce8fa52be4dc442e1a28298c92fa96c131 Mon Sep 17 00:00:00 2001 From: Maximilian S Date: Sun, 16 Dec 2018 16:24:05 +0100 Subject: [PATCH] Fixed missing URL for Upload and Download --- .../com/seafile/seadroid2/SeafConnection.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/seafile/seadroid2/SeafConnection.java b/app/src/main/java/com/seafile/seadroid2/SeafConnection.java index 8e0957b53..cfc12f54d 100644 --- a/app/src/main/java/com/seafile/seadroid2/SeafConnection.java +++ b/app/src/main/java/com/seafile/seadroid2/SeafConnection.java @@ -459,12 +459,18 @@ public Pair getDownloadLink(String repoID, String path ,boolean checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK); String result = new String(req.bytes(), "UTF-8"); - String fileID = req.header("oid"); + result = result.replace("\"", ""); // remove quotation marks + + // Fix missing URL + if (!result.startsWith("http")) { + result = account.server + result; + result = result.replaceAll("(?(url, fileID); + String fileID = req.header("oid"); + // should return "http://gonggeng.org:8082/..." or "https://gonggeng.org:8082/..." + if (fileID != null) { + return new Pair(result, fileID); } else { throw SeafException.illFormatException; } @@ -780,12 +786,16 @@ private String getUploadLink(String repoID, boolean update) throws SeafException checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK); String result = new String(req.bytes(), "UTF-8"); - // should return "\"http://gonggeng.org:8082/...\"" or "\"https://gonggeng.org:8082/...\" - if (result.startsWith("\"http")) { - // remove the starting and trailing quote - return result.substring(1, result.length() - 1); - } else - throw SeafException.unknownException; + result = result.replace("\"", ""); // remove quotation marks + + // Fix missing URL + if (!result.startsWith("http")) { + result = account.server + result; + result = result.replaceAll("(?