Skip to content

Commit 9108bda

Browse files
committed
Emit devdock example result
1 parent f444876 commit 9108bda

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

example/src/main/java/io/tus/java/example/Api2DevdockTusUpload.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static void main(String[] args) {
3030
final JSONObject scenario = loadScenario();
3131
final JSONObject createResponse = scenario.getJSONObject("prepared").getJSONObject("createResponse");
3232
final String uploadUrl = uploadWithTus(scenario, createResponse);
33+
writeResult(uploadUrl);
3334

3435
System.out.println(
3536
"Java TUS SDK devdock scenario "
@@ -53,6 +54,20 @@ private static JSONObject loadScenario() throws IOException {
5354
return new JSONObject(new String(contents, StandardCharsets.UTF_8));
5455
}
5556

57+
private static void writeResult(String uploadUrl) throws IOException {
58+
final String resultPath = System.getenv("API2_SDK_EXAMPLE_RESULT");
59+
if (resultPath == null || resultPath.isEmpty()) {
60+
return;
61+
}
62+
63+
final JSONObject result = new JSONObject();
64+
result.put("uploadUrl", uploadUrl);
65+
Files.write(
66+
Paths.get(resultPath),
67+
(result.toString(2) + "\n").getBytes(StandardCharsets.UTF_8)
68+
);
69+
}
70+
5671
private static String uploadWithTus(
5772
JSONObject scenario,
5873
JSONObject createResponse

0 commit comments

Comments
 (0)