Skip to content

Commit d1c94b3

Browse files
authored
set default options if call Cloud (#1345)
Signed-off-by: lentitude2tk <[email protected]>
1 parent 9e1b746 commit d1c94b3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/BaseBulkImport.java

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
public class BaseBulkImport {
3131
protected static String postRequest(String url, String apiKey, Map<String, Object> params, int timeout) {
3232
try {
33+
setDefaultOptionsIfCallCloud(params, apiKey);
3334
kong.unirest.HttpResponse<String> response = Unirest.post(url)
3435
.connectTimeout(timeout)
3536
.headers(httpHeaders(apiKey))
@@ -85,4 +86,14 @@ protected static void handleResponse(String url, RestfulResponse res) {
8586
ExceptionUtils.throwUnExpectedException(String.format("Failed to request url: %s, code: %s, message: %s", url, innerCode, innerMessage));
8687
}
8788
}
89+
90+
private static void setDefaultOptionsIfCallCloud(Map<String, Object> params, String apiKey) {
91+
if (StringUtils.isNotEmpty(apiKey)) {
92+
Map<String, Object> options = new HashMap<>();
93+
options.put("sdk", "java");
94+
options.put("scene", "bulkWriter");
95+
96+
params.put("options", options);
97+
}
98+
}
8899
}

0 commit comments

Comments
 (0)