In Karate 0.9.6, I had to add * configure charset = null for plain text upload to work, when I upgraded to 1.0.1, I can't find any way that works for plain text.
my pom:
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
my Scenario:
Given path uuid, 'upload'
And multipart file file = ({read: filePath + fileName, filename: fileName, contentType: contentType})
And configure charset = null
When method POST
Then status 200
This works for images and pdf files but not with txt files with contentType = "plain/text"
The backend is a springboot app. The service contains the parameter @RequestPart(value = "file") MultipartFile content) , and the file is validated like this
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile
private boolean hasSupportedContentType(MultiPartFile multipartfile) {
String contentType = multipartFile.getContentType();
return contentType.equals(MediaType.TEXT_PLAIN_VALUE)
|| contentType.equals(MediaType.APPLICATION_PDF_VALUE);
}
The following throws and excpetion because hasSupportedContentType is false.
Is there any workaround this problem?