Open Hansanto opened 3 weeks ago
Also, I tried to set name="..."
in header for the Content-Disposition
but it's override during the request to use the @RequestParam.name
or ,variable name from function signature
I'm not able to address your description in detail, because the premise at the start that you need to create a Part
is incorrect. We do support Part
, and that's useful if you need to make a remote call from a controller, but we don't expect you to create one.
The supported types for @RequestPart
are listed in the reference docs.
Add a request part, which may be a String (form field), Resource (file part), Object (entity to be encoded, e.g. as JSON), HttpEntity (part content and headers), a Spring Part, or Reactive Streams Publisher of any of the above.
Generally I'm also not sure why using the variable name or the annotation to give the part a name is an issue.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Affects:
Context
Hello
I'm trying to use HTTP Interface to send Multipart data. My goal is to send 2 part. So I write this function:
Service
Part
I think we need to create our own Part (I didn't find any usable implementation), so I create one for
byte[]
and other forjson
Service usage
I'm using the service and part like that:
Requests
Result without annotation parameters
With the service's function with this definition:
The following request will be generated
Problem
As you can see in the request, in the
Content-Disposition
value, thename
is corresponding to the variable defined in the definition of the function and not the name from thePart
values.The function
Part.name()
is never used to obtain the name of the Part.Result with annotation parameters
With the service's function with this definition:
The following request will be generated
Problem
As you can see in the request, in the
Content-Disposition
value, thename
is corresponding to the value sent in@RequestPart("XXX")
for each part, but like the previous case the functionPart.name()
is never used to obtain the name of the Part.Other tests
For my
Part
implementations, I replaced the:by
And as expected, no error has been thrown during the request. (Same in debug mode, the breakpoint is never used)
Expectation
The priority to define the multipart name should be:
Part name defined
If the name in
Part
implementation is defined, the name should be used asname
in multipart contentSo the values in multipart content should be:
even if the
@RequestPart.name
is defined. The name fromPart
should override it.Part name not defined
If the name in
Part
implementation is not defined, the@RequestPart.name
should be used asname
in multipart contentAnd the service:
So the values in multipart content should be:
Not name defined
If
Part.name
and@RequestPart.name
are not defined, the name of the variable in the function signature should be used.So the values in multipart content should be: