Skip to content

Commit

Permalink
ServerUpdate (#846)
Browse files Browse the repository at this point in the history
* Server update

* update

* URLEncoded

* amend URLEncoded
  • Loading branch information
maxiaoping authored and freeplant committed Jan 6, 2020
1 parent 9308e27 commit 5675400
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId 'com.seafile.seadroid2'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 98
versionName "2.2.23"
versionCode 99
versionName "2.2.24"
multiDexEnabled true
resValue "string", "authorities", applicationId + '.cameraupload.provider'
resValue "string", "account_type", "com.seafile.seadroid2.account.api2"
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/seafile/seadroid2/SeafConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,13 @@ public boolean setPassword(String repoID, String passwd) throws SeafException {
return false;
}

private String getUploadLink(String repoID, boolean update) throws SeafException {
private String getUploadLink(String repoID, boolean update, String dir) throws SeafException {
try {
String apiPath;
if (update) {
apiPath = "api2/repos/" + repoID + "/update-link/";
} else {
apiPath = "api2/repos/" + repoID + "/upload-link/";
apiPath = "api2/repos/" + repoID + "/upload-link/?p=" + Utils.toURLEncoded(dir);
}
HttpRequest req;
req = prepareApiGetRequest(apiPath);
Expand Down Expand Up @@ -879,7 +879,7 @@ private String commitUpload(String link, List<String> blkIds, String dir, String
*/
public String uploadFile(String repoID, String dir, String filePath, ProgressMonitor monitor, boolean update)
throws SeafException, IOException {
String url = getUploadLink(repoID, update);
String url = getUploadLink(repoID, update, dir);
return uploadFileCommon(url, repoID, dir, filePath, monitor, update);
}

Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/seafile/seadroid2/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
Expand Down Expand Up @@ -931,4 +932,17 @@ public static String getUploadStateShow(Context context) {
}
return results;
}

public static String toURLEncoded(String paramString) {
if (paramString == null || paramString.equals("")) {
return "";
}
try {
String str = new String(paramString.getBytes(), "UTF-8");
str = URLEncoder.encode(str, "UTF-8");
return str;
} catch (Exception localException) {
}
return "";
}
}

0 comments on commit 5675400

Please sign in to comment.