我在Azure Blobstorage上上传了PDF,在下载例程中我遇到了一些问题。
我的应用程序与Springboot一起运行,我使用 outputStream
由 httpservletResponse
提供的在 @restcontroller
中。
在前端,我有一个REAC应用程序,可以接收信息并通过浏览器执行下载。
每次将字节流到前端时,我都会收到一个损坏的文件。当我通过失眠或邮递员执行请求时,它可以正常工作。
我试图将这些文件作为文本进行比较,可以看到它们之间的一些差异。
差异
- 损坏文件的大小几乎是原始文件的大小的两倍

- 当我在记事本++上打开文件时,它们似乎在其他编码中
损坏
一致的
- 看起来有些字符不好解释
损坏
一致的
我的前端使用 filesaver
@2.0.2在磁盘上坚持文件
const blobParts = [];
const blobOptions = {
type: axiosResponse.headers['content-type'],
};
blobParts.push(axiosResponse.data);
const file = new File(
blobParts,
axiosResponse.headers['content-disposition'].split('=')[1],
blobOptions,
);
return FileSaver.saveAs(file);
我想知道是否有一种方法可以使ANSI通过该文件进行编码持久过程或是否有办法
I have a pdf uploaded in a Azure Blobstorage and I'm facing some problems during the download routine.
My application runs with springboot and I use an OutputStream
provided by a HttpServletResponse
in a @RestController
method to stream the bytes from the blobstorage to the request.
In the frontend I have a Reac application receiving the information and executing the download through the browser.
Every time I stream the bytes to the frontend I got a corrupted file. It works just fine when I execute a request through Insomnia or Postman.
I tried to compare the files as texts and I could see some differences between them.
Differences
- The size of the corrupted file is almost double the size of the original

- When I opened files on Notepad++ they seems to be in a different encoding
corrupted

consistent

- It looks like there are some characters bad interpreted
corrupted

consistent

My frontend uses FileSaver
@2.0.2 to persist the file on disk
const blobParts = [];
const blobOptions = {
type: axiosResponse.headers['content-type'],
};
blobParts.push(axiosResponse.data);
const file = new File(
blobParts,
axiosResponse.headers['content-disposition'].split('=')[1],
blobOptions,
);
return FileSaver.saveAs(file);
I'm wondering if there's a way of keep the ANSI encoding through the persistence process or if there's is a way
发布评论