Skip to content

Commit e7f247a

Browse files
Allow android unsigned upload without api_key
1 parent 58d8606 commit e7f247a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

cloudinary-android/src/main/java/com/cloudinary/android/UploaderStrategy.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,24 @@ public Map callApi(String action, Map<String, Object> params, Map options, Objec
2727
}
2828
boolean returnError = ObjectUtils.asBoolean(options.get("return_error"), false);
2929

30-
String apiKey = ObjectUtils.asString(options.get("api_key"), this.cloudinary().config.apiKey);
31-
if (apiKey == null)
32-
throw new IllegalArgumentException("Must supply api_key");
33-
3430
if (Boolean.TRUE.equals(options.get("unsigned"))) {
3531
// Nothing to do
36-
} else if (options.containsKey("signature") && options.containsKey("timestamp")) {
37-
params.put("timestamp", options.get("timestamp"));
38-
params.put("signature", options.get("signature"));
39-
params.put("api_key", apiKey);
4032
} else {
41-
String apiSecret = ObjectUtils.asString(options.get("api_secret"), this.cloudinary().config.apiSecret);
42-
if (apiSecret == null)
43-
throw new IllegalArgumentException("Must supply api_secret");
44-
params.put("timestamp", Long.valueOf(System.currentTimeMillis() / 1000L).toString());
45-
params.put("signature", this.cloudinary().apiSignRequest(params, apiSecret));
46-
params.put("api_key", apiKey);
33+
String apiKey = ObjectUtils.asString(options.get("api_key"), this.cloudinary().config.apiKey);
34+
if (apiKey == null)
35+
throw new IllegalArgumentException("Must supply api_key");
36+
if (options.containsKey("signature") && options.containsKey("timestamp")) {
37+
params.put("timestamp", options.get("timestamp"));
38+
params.put("signature", options.get("signature"));
39+
params.put("api_key", apiKey);
40+
} else {
41+
String apiSecret = ObjectUtils.asString(options.get("api_secret"), this.cloudinary().config.apiSecret);
42+
if (apiSecret == null)
43+
throw new IllegalArgumentException("Must supply api_secret");
44+
params.put("timestamp", Long.valueOf(System.currentTimeMillis() / 1000L).toString());
45+
params.put("signature", this.cloudinary().apiSignRequest(params, apiSecret));
46+
params.put("api_key", apiKey);
47+
}
4748
}
4849
String apiUrl = this.cloudinary().cloudinaryApiUrl(action, options);
4950
MultipartUtility multipart = new MultipartUtility(apiUrl, "UTF-8", this.cloudinary().randomPublicId(), (String) options.get("content_range"));

0 commit comments

Comments
 (0)