排除内容元数据添加到使用WebClient Springboot的文件上传的内容
我正在尝试使用Spring引导中的WebClient上传到FTP服务器。
以下是我的代码:
URI uri = new URI(domain +folderName+ fileName);
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("file", resource);
ResponseEntity<Object> response = webClient.put().uri(uri).contentType(MediaType.MULTIPART_FORM_DATA)
.header(HttpHeaders.AUTHORIZATION, auth)
.body(BodyInserters.fromMultipartData(builder.build())).retrieve().toEntity(Object.class).block();
但是,当文件上传时,我可以看到内容元数据包含在文件顶部,如下所示:
如何避免在文件中添加此内容元数据?
I am trying to upload a file to ftp server using WebClient in spring boot.
Below is my code:
URI uri = new URI(domain +folderName+ fileName);
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("file", resource);
ResponseEntity<Object> response = webClient.put().uri(uri).contentType(MediaType.MULTIPART_FORM_DATA)
.header(HttpHeaders.AUTHORIZATION, auth)
.body(BodyInserters.fromMultipartData(builder.build())).retrieve().toEntity(Object.class).block();
However, when the file gets uploaded, I can see content meta-data being included at the top of the file as seen below:
How do I avoid this content meta-data getting added in my file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用
frommultipartdata(builder.build())
fromResource(new filesystemsource(resource))
,您可以完全删除
我知道我在这里迟到了,但是这个答案可以帮助某人
Replace
fromMultipartData(builder.build())
withfromResource(new FileSystemResource(resource))
and you can completely remove
I know i am late here, but this answer may assist someone