I want test JSON Send as multipart/form-data. So, I change JSON String into File With Blob.
But the k6 is not include Blob library.
my k6 code is below
export default function () {
let url = "http://localhost:8080/products/1/reviews";
const fd = new FormData();
const reviewJSON = JSON.stringify({
userId : 1,
score : Math.random() * 5 + 1,
content : '리뷰 내용',
})
const blob = new Blob([reviewJSON], {
type: "application/json",
});
fd.append('review', blob);
http.post(url, fd.body(), {
headers: { 'Content-Type': 'multipart/form-data; boundary=' + fd.boundary },
});
sleep(1);
}
my Test Spring API is below
@PostMapping
public ResponseEntity<?> createProductReview(
@PathVariable("productId") Long productId,
@RequestPart(required = false) MultipartFile file,
@RequestPart("review") @Valid CreateProductReviewRequest request
) { ... }