简体   繁体   English

我们可以从byteArrayResource获取文件名吗?

[英]can we get filename from byteArrayResource?

It's about uploading xlsx file. 关于上传xlsx文件。 Initially im getting xlsx file as javax.servlet.http.Part and trying to convert as ByteArrayResource Since i need to pass via RestTemplate . 最初我将xlsx文件获取为javax.servlet.http.Part并尝试转换为ByteArrayResource因为我需要通过RestTemplate传递。

new ByteArrayResource(IOUtils.toByteArray(input.getFile().getInputStream())

Here input.getFile() is javax.servlet.http.Part 这里input.getFile()javax.servlet.http.Part

As im converting here into ByteArrayResource and sending back to another Layer for business logic, can i get filename from ByteArrayResource ? 当我在这里将其转换为ByteArrayResource并发送回另一层用于业务逻辑时,我可以从ByteArrayResource获取filename吗?

Anyhow we can get filename from Part , I want to know is that possible to get filename from ByteArrayResource or ByteArray ? 无论如何,我们都可以从Part获取filename ,我想知道是否可以从ByteArrayResourceByteArray获取filename

You'll probably need to use FileNameAwareByteArrayResource as outlined in this answer 您可能需要使用此答案中概述的FileNameAwareByteArrayResource

https://stackoverflow.com/questions/42416015/spring-boot-multipartfile-issue-with-bytearrayresource

and you'll be able to get filename from it then. 然后您就可以从中获取文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM