First of all i share my api doc
Document said image will send to header not body
And I wrote thsese codes
public Response uploadFile(){
File upload = new File("senna.jpg");
String uuid = getUuid();
return given()
.baseUri(getBaseUrl())
.accept("application/json")
.header("Accept-Encoding","gzip, deflate, br")
// .header("Content-Type","image/jpg")
.contentType(ContentType.MULTIPART)
.header("X-Auth-Token",payload.userAuth())
.header("X-Meta-Strategy","1")
// .header("X-Object-Meta-File-Name",upload)
.multiPart("X-Object-Meta-File-Name",upload,"image/jpg")
.when().put("/" uuid).then().log().all().assertThat().extract().response();
}
This code upload an image with doc format not png. So i tried multipart and .header() method both of them didn't work. If i use .header("Content-Type","image/jpg")
& .header("X-Object-Meta-File-Name",upload)
i got this error
Cannot serialize because cannot determine how to serialize content-type image/jpg
I know content type doesn't allow image/jpg.
So how can do that ? Thank you in advance
CodePudding user response:
Document was wrong and i added the body(upload)
public Response uploadFile(){
File upload = new File("senna.jpg");
String uuid = getUuid();
return given()
.baseUri(getBaseUrl())
.accept("application/json")
.header("Content-Type","image/jpg")
.header("X-Object-Meta-File-Name","senna.jpg")
.header("X-Auth-Token",payload.userAuth())
.header("X-Meta-Strategy","1")
.body(upload)
.when().put("/" uuid).then().log().all().assertThat().extract().response();
}
Thank you
Alexey R.