Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能否对blob进行独立的支持? #591

Open
Lands-1203 opened this issue Sep 9, 2024 · 3 comments
Open

能否对blob进行独立的支持? #591

Lands-1203 opened this issue Sep 9, 2024 · 3 comments

Comments

@Lands-1203
Copy link

当前http有两种预览方式 :http://127.0.0.1:8080/filedownload?fileId=1http://127.0.0.1:8080/file/test.txt
这两种方式本质上都是通过url访问的,在旧系统中可能无法支持这样的方式。
预期结果
根据kkfile的预览原理,是后端获取到url后再对文件进行请求,但是现在文件有各种请求头、请求方式(get\post)、sessionToken、url、等。所以能否在kkfile的访问地址上上传多个参数:用于告诉kkfile对文件的访问地址呢?我觉得这样是一个合理的支持:
例如:127.0.0.1:8012?type=requestFile&url=encodeURIComponent(url)&method=get&params=encodeURIComponent(params)&body=encodeURIComponent(body)&headers=encodeURIComponent(headers)&responseType=blob

解释:

  • type=requestFile 代表当前要进行参数组装
  • url=encodeURIComponent(url) 代表文件的请求地址
  • method=get 代表请求方式
  • params=encodeURIComponent(params) 代表请求url的query参数
  • body=encodeURIComponent(body) 代表请求体参数
  • headers=encodeURIComponent(headers) 代表请求头
  • responseType: 'blob' 见:XMLHttpRequest https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest/responseType
    image
@Lands-1203
Copy link
Author

Lands-1203 commented Sep 9, 2024

后端在获取到这些参数后进行参数组装在对服务器进行请求

@gaoxingzaq
Copy link
Contributor

需要重构下载方法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Lands-1203 @gaoxingzaq and others