From a0fe803c35719018ce5ed90c8d723def0ce34c3f Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 5 Nov 2021 14:46:22 +0000 Subject: [PATCH] Added POST /arbitrary/{service}/{name} API endpoint At the moment this just redirects to PUT, but will ultimately choose PUT or PATCH based on the differences in the data supplied. --- .../api/resource/ArbitraryResource.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/main/java/org/qortal/api/resource/ArbitraryResource.java b/src/main/java/org/qortal/api/resource/ArbitraryResource.java index 82ac1f30..ba2ce3a1 100644 --- a/src/main/java/org/qortal/api/resource/ArbitraryResource.java +++ b/src/main/java/org/qortal/api/resource/ArbitraryResource.java @@ -289,6 +289,41 @@ public class ArbitraryResource { } } + @POST + @Path("/{service}/{name}") + @Operation( + summary = "Build raw, unsigned, ARBITRARY transaction, based on a user-supplied path", + description = "A POST transaction automatically selects a PUT or PATCH method based on the data supplied", + requestBody = @RequestBody( + required = true, + content = @Content( + mediaType = MediaType.TEXT_PLAIN, + schema = @Schema( + type = "string", example = "/Users/user/Documents/MyDirectoryOrFile" + ) + ) + ), + responses = { + @ApiResponse( + description = "raw, unsigned, ARBITRARY transaction encoded in Base58", + content = @Content( + mediaType = MediaType.TEXT_PLAIN, + schema = @Schema( + type = "string" + ) + ) + ) + } + ) + public String post(@PathParam("service") String serviceString, + @PathParam("name") String name, + String path) { + Security.checkApiCallAllowed(request); + + // TODO: automatic PUT/PATCH + return this.upload(Method.PUT, Service.valueOf(serviceString), name, path); + } + @PUT @Path("/{service}/{name}") @Operation(