Java - byte[] 到 FileItem

发布于 2025-01-07 11:04:09 字数 364 浏览 3 评论 0原文

我正在使用 JasperReports 生成 PDF,它以字节数组 byte[] 的形式提供 PDF。

我想将原始字节传递给另一个需要 FileItem 对象形式的文件的函数。特别是,FileItem 来自 Apache Commons 库 org.apache.commons.fileupload.FileItem。

// the function I want to pass it into
public DocumentDO toDocumentDO(FileItem fileItem);

有什么方法可以做到这一点还是不可能(即 byte[] 不包含成为 FileItem 所需的元数据,如文件名、mime 类型等)?

I'm using JasperReports to generate PDFs, and it gives me the PDF as a byte array, byte[].

I want to pass the raw bytes to another function that needs the file in terms of a FileItem object. In particular, the FileItem is from the Apache Commons library org.apache.commons.fileupload.FileItem.

// the function I want to pass it into
public DocumentDO toDocumentDO(FileItem fileItem);

Is there any way to do that or is it not possible (ie. the byte[] doesn't contain the metadata needed for it to be a FileItem like filename, mime type, etc)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬色的秋千 2025-01-14 11:04:09

您的字节数组就是它的本质 - 一堆原始字节,您提到的所有元数据都需要单独提供,除非您将其读入文件,然后解析文件以获取嵌入的元信息

Your byte array is just what it is - bunch ow raw bytes, all meta data that you mentioned needs to be provided separately unless you read it into the file and then parse the file for the embedded meta information

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文