fix(plugins): Use InputStream for plugin binary body
@@ -18,9 +18,12 @@ package com.netflix.spinnaker.front50.controllers;
import static java.lang.String.format;
import com.google.common.hash.Hashing;
+import com.google.common.io.ByteStreams;
import com.netflix.spinnaker.front50.plugins.PluginBinaryStorageService;
import com.netflix.spinnaker.kork.exceptions.SystemException;
+import java.io.InputStream;
import java.util.Optional;
+import lombok.SneakyThrows;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -35,15 +38,17 @@ public class PluginBinaryController {
this.pluginBinaryStorageService = pluginBinaryStorageService;
}
+ @SneakyThrows
@PostMapping("/{id}/{version}")
@ResponseStatus(HttpStatus.CREATED)
void upload(
@PathVariable String id,
@PathVariable String version,
@RequestParam("sha512sum") String sha512sum,
- @RequestBody byte[] body) {
- verifyChecksum(body, sha512sum);
- storageService().store(getKey(id, version), body);
+ InputStream body) {
+ byte[] bytes = ByteStreams.toByteArray(body);
+ verifyChecksum(bytes, sha512sum);
+ storageService().store(getKey(id, version), bytes);
}
@GetMapping("/{id}/{version}")
