Closed silentbalanceyh closed 3 years ago
Append:
http://localhost:6201/api/attachment/upload/hotel ( Working ) http://localhost:6100/api/attachment/upload/hotel ( Issue position )
When I send request to 6201, I can get attachment information as following:
{
"key" : "7941105d-b041-44f4-81ab-9c22592f5e57",
"storeWay" : "FILE",
"status" : "PROGRESS",
"name" : "《美丽的黄昏》定稿 2.doc",
"fileKey" : "S681B1SF7mrAjtMRSx5tfiHIuEAfImlLzqcz09H8ZFnkMrQXUsGiCjdF0N7IWl9o",
"fileName" : "《美丽的黄昏》定稿 2",
"fileUrl" : "/api/attachment/download/7941105d-b041-44f4-81ab-9c22592f5e57",
"filePath" : "file-uploads/5bc90d20-8fba-4892-ab70-6139fad83dff",
"extension" : "doc",
"module" : "hotel",
"mime" : "application/msword",
"size" : 46080,
"language" : "cn",
"metadata" : "{}"
}
But when the same request send to Api Gateway ( 6100 ) and forward to 6201, this issue reproduce.
I think following code should be helpful, I send request with Apache Http Client, it also works:
final CloseableHttpAsyncClient client = HttpAsyncClients.createDefault();
client.start();
final File file = new File("data-test");
final HttpPost post = new HttpPost(
"http://localhost:6201/api/attachment/upload/hotel");
final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY);
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("file", fileBody);
final HttpEntity entity = builder.build();
post.setEntity(entity);
final Future<HttpResponse> response = client.execute(post, null);
final HttpResponse data = response.get();
But I could not find MultipartEntityBuilder code in vert.x HttpClient/WebClient here, could some one provide helps to me here ?
I resolved this issue in another way, I used http client internally instead of WebClient/HttpClient, but I don't know whether this solution is standard here ? Now I can get the data from FileUpload.
can you provide a failing test in this project in the HttpTest
class ?
@silentbalanceyh I am facing the same issue. Possible for you to share the repository link where you resolved this issue. Been stuck on this for more than a week now, not able to figure out what is wrong in WebClient of vertx
Closing, if you can provide a simple reproducer (a few classes) then feel free to reopen.
Version
Context
I met an issue when I write following code here, there are two projects:
Testing uri is:
I refer upload coding demo: https://github.com/vert-x/vertx-examples/blob/master/src/raw/java/upload/UploadClient.java
When I send request with postman with attachment, here are the http headers came from postman
Do you have a reproducer?
You can download the project and start two projects to reproduce.
Steps to reproduce
You can see the log as following: it means that it's running:
Service:
Gateway:
Extra
I tested with HttpClient/WebClient, all these client will let the Set to empty, but when I used postman send the request directly, it's working. It means that the service should be fine. It also prove the lightweight framework should be working. But when I used the code from:
https://github.com/vert-x/vertx-examples/blob/master/src/raw/java/upload/UploadClient.java
I can see the set size is 0, but request also is multipart:
Actually, if I set Api Gateway act file uploading server, this issue could be ignored here, but I think there should be a method to tell me that the HttpClient/WebClient could do this kind of file uploading. Could someone help to resolve this issue ?
The expected situation is that:
When I send request to api gateway, api gateway could forwarded our file uploading request to other micro service, at least other micro service should get the FileUpload object.