|
44 | 44 | import jakarta.ws.rs.ext.MessageBodyWriter; |
45 | 45 | import jakarta.ws.rs.ext.Provider; |
46 | 46 | import jakarta.ws.rs.ext.Providers; |
47 | | -import org.apache.cxf.attachment.AttachmentUtil; |
48 | 47 | import org.apache.cxf.common.logging.LogUtils; |
49 | 48 | import org.apache.cxf.common.util.StringUtils; |
50 | 49 | import org.apache.cxf.helpers.CastUtils; |
@@ -161,13 +160,13 @@ private <T> EntityPart fromAttachment(Attachment attachment, Class<T> c, final T |
161 | 160 | final String fileName = (cd != null) ? cd.getFilename() : null; |
162 | 161 | final String cdName = cd == null ? null : cd.getParameter("name"); |
163 | 162 | final String contentId = attachment.getContentId(); |
164 | | - final String name = StringUtils.isEmpty(cdName) ? contentId : cdName.replace("\"", "").replace("'", ""); |
165 | 163 |
|
166 | 164 | if (!StringUtils.isEmpty(fileName)) { |
167 | | - return new EntityPartImpl(mc.getProviders(), name, fileName, is, c, genericType, headers, |
168 | | - attachment.getContentType()); |
| 165 | + return new EntityPartImpl(mc.getProviders(), contentId, fileName, is, c, genericType, |
| 166 | + attachment.getHeaders(), attachment.getContentType()); |
169 | 167 | } else { |
170 | | - return new EntityPartImpl(mc.getProviders(), name, null, is, c, genericType, headers, |
| 168 | + final String name = StringUtils.isEmpty(cdName) ? contentId : cdName.replace("\"", "").replace("'", ""); |
| 169 | + return new EntityPartImpl(mc.getProviders(), name, null, is, c, genericType, attachment.getHeaders(), |
171 | 170 | attachment.getContentType()); |
172 | 171 | } |
173 | 172 | } else { |
@@ -207,7 +206,7 @@ private static <T> Attachment createDataHandler(final EntityPart part, final Cla |
207 | 206 | return part.getFileName() |
208 | 207 | .map(fileName -> { |
209 | 208 | final ContentDisposition cd = new ContentDisposition("form-data;name=file;filename=" + fileName); |
210 | | - return new Attachment(AttachmentUtil.BODY_ATTACHMENT_ID, part.getContent(), cd); |
| 209 | + return new Attachment(part.getName(), part.getContent(), cd); |
211 | 210 | }) |
212 | 211 | .orElseGet(() -> { |
213 | 212 | headers.putSingle("Content-Type", mt); |
|
0 commit comments