muffin-admin 3.14.0 → 3.15.0
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/dist/dataprovider.js +6 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/dataprovider.ts +5 -1
package/dist/dataprovider.js
CHANGED
|
@@ -102,13 +102,18 @@ export function MuffinDataprovider(apiUrl) {
|
|
|
102
102
|
return { data: json };
|
|
103
103
|
}),
|
|
104
104
|
downloadFile: (path) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
var _a;
|
|
106
|
+
path = path.replace(/^\/+/, "");
|
|
105
107
|
const response = yield fetch(`${apiUrl}/${path}`, {
|
|
106
108
|
headers: requestHeaders,
|
|
107
109
|
});
|
|
108
110
|
const url = window.URL.createObjectURL(yield response.blob());
|
|
109
111
|
const link = document.createElement("a");
|
|
110
112
|
link.href = url;
|
|
111
|
-
|
|
113
|
+
const filename = ((_a = response.headers.get("content-disposition")) === null || _a === void 0 ? void 0 : _a.split("filename=")[1]) || path.split("/").pop();
|
|
114
|
+
link.setAttribute("download", filename);
|
|
115
|
+
if (filename)
|
|
116
|
+
link.setAttribute("download", filename);
|
|
112
117
|
link.click();
|
|
113
118
|
// no need to append link as child to body.
|
|
114
119
|
setTimeout(() => window.URL.revokeObjectURL(url), 0); // this is important too, otherwise we will be unnecessarily spiking memory!
|