@irontec/ivoz-ui 1.7.18 → 1.7.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/List/DownloadFile.js +3 -3
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1 -0
- package/helpers/parseContentDispositionFilename.d.ts +1 -0
- package/helpers/parseContentDispositionFilename.js +12 -0
- package/package.json +1 -1
- package/services/form/Field/FileUploader/FileUploader.js +3 -3
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { useStoreActions } from 'store';
|
|
12
12
|
import { saveAs } from 'file-saver';
|
|
13
|
+
import { parseContentDispositionFilename } from '../../helpers';
|
|
13
14
|
import { Tooltip } from '@mui/material';
|
|
14
15
|
import DownloadIcon from '@mui/icons-material/Download';
|
|
15
16
|
import { StyledPdfButton } from './DownloadFile.styles';
|
|
@@ -23,9 +24,8 @@ export default function DownloadFile(props) {
|
|
|
23
24
|
path: `${path}/${row.id}/${fileType}`,
|
|
24
25
|
params: {},
|
|
25
26
|
successCallback: (data, headers) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
saveAs(data, fileName || 'download');
|
|
27
|
+
const fileName = parseContentDispositionFilename(headers['content-disposition'] || '');
|
|
28
|
+
saveAs(data, fileName);
|
|
29
29
|
}),
|
|
30
30
|
});
|
|
31
31
|
};
|
package/helpers/index.d.ts
CHANGED
package/helpers/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseContentDispositionFilename(contentDisposition: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function parseContentDispositionFilename(contentDisposition) {
|
|
2
|
+
var _a;
|
|
3
|
+
const filenameStar = contentDisposition.match(/filename\*\s*=\s*([^']*)'([^']*)'((?:%[0-9A-Fa-f]{2}|[!#$&+\-.^_`|~\w])+)/i);
|
|
4
|
+
if (filenameStar) {
|
|
5
|
+
return decodeURIComponent(filenameStar[3]);
|
|
6
|
+
}
|
|
7
|
+
const filename = contentDisposition.match(/filename\s*=\s*(?:"([^"]*)"|([^;\s]+))/i);
|
|
8
|
+
if (filename) {
|
|
9
|
+
return (_a = filename[1]) !== null && _a !== void 0 ? _a : filename[2];
|
|
10
|
+
}
|
|
11
|
+
return 'download';
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { saveAs } from 'file-saver';
|
|
12
|
+
import { parseContentDispositionFilename } from '../../../../helpers';
|
|
12
13
|
import { useCallback, useState, } from 'react';
|
|
13
14
|
import { useStoreActions } from '../../../../store';
|
|
14
15
|
import { StyledFieldsetRoot } from '../CustomComponentWrapper.styles';
|
|
@@ -52,9 +53,8 @@ const FileUploader = (props) => {
|
|
|
52
53
|
path: downloadPath,
|
|
53
54
|
params: {},
|
|
54
55
|
successCallback: (data, headers) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
saveAs(data, fileName || 'download');
|
|
56
|
+
const fileName = parseContentDispositionFilename(headers['content-disposition'] || '');
|
|
57
|
+
saveAs(data, fileName);
|
|
58
58
|
}),
|
|
59
59
|
});
|
|
60
60
|
}
|