mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
fix(custom-request): unable to download utf-8 encoded files (#6541)
This commit is contained in:
parent
38bac8291e
commit
3b86eccca4
@ -67,10 +67,13 @@ export const useCustomizeRequestActionProps = () => {
|
||||
responseType: fieldSchema['x-response-type'] === 'stream' ? 'blob' : 'json',
|
||||
});
|
||||
if (res.headers['content-disposition']) {
|
||||
const regex = /attachment;\s*filename="([^"]+)"/;
|
||||
const match = res.headers['content-disposition'].match(regex);
|
||||
if (match?.[1]) {
|
||||
saveAs(res.data, match[1]);
|
||||
const contentDisposition = res.headers['content-disposition'];
|
||||
const utf8Match = contentDisposition.match(/filename\*=utf-8''([^;]+)/i);
|
||||
const asciiMatch = contentDisposition.match(/filename="([^"]+)"/i);
|
||||
if (utf8Match) {
|
||||
saveAs(res.data, decodeURIComponent(utf8Match[1]));
|
||||
} else if (asciiMatch) {
|
||||
saveAs(res.data, asciiMatch[1]);
|
||||
}
|
||||
}
|
||||
actionField.data.loading = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user