Skip to content

Commit 7909cb5

Browse files
committed
Fix file download issue for actions.
1 parent abeae1d commit 7909cb5

6 files changed

Lines changed: 111 additions & 58 deletions

File tree

docs/build.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def read_cls_docstring(cls):
4242

4343
def get_versions():
4444
return [
45+
{
46+
"version": "0.3.10",
47+
"changes": [
48+
"Fix file download issue for actions.",
49+
],
50+
},
4551
{
4652
"version": "0.3.9",
4753
"changes": [

docs/index.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ <h4 class="title">FastAdmin</h4>
196196

197197
<ul class="nav flex-column">
198198

199+
<li class="nav-item">
200+
<a class="nav-link" href="#v0_3_10">v0.3.10</a>
201+
</li>
202+
199203
<li class="nav-item">
200204
<a class="nav-link" href="#v0_3_9">v0.3.9</a>
201205
</li>
@@ -343,7 +347,7 @@ <h1>FastAdmin | Documentation</h1>
343347
<div class="row">
344348
<div class="col-sm-6 col-lg-4">
345349
<ul class="list-unstyled">
346-
<li><strong>Version:</strong> 0.3.9</li>
350+
<li><strong>Version:</strong> 0.3.10</li>
347351
<li>
348352
<strong>Author:</strong>
349353
<a href="mailto:vsdudakov@gmail.com" target="_blank">
@@ -3376,6 +3380,31 @@ <h2>Changelog</h2>
33763380

33773381

33783382

3383+
<section id="v0_3_10">
3384+
<h3>v0.3.10</h3>
3385+
3386+
3387+
3388+
<p class="text-4">
3389+
Fix file download issue for actions.
3390+
</p>
3391+
3392+
3393+
3394+
3395+
3396+
3397+
3398+
3399+
3400+
3401+
3402+
3403+
3404+
3405+
</section>
3406+
3407+
33793408
<section id="v0_3_9">
33803409
<h3>v0.3.9</h3>
33813410

fastadmin/static/index.min.js

Lines changed: 52 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/components/inline-widget/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,18 @@ export const InlineWidget: React.FC<IInlineWidget> = ({
206206
break;
207207
case EActionResponseType.DOWNLOAD_BASE64: {
208208
const fileBase64 = response.data;
209-
const fileBuffer = atob(fileBase64);
209+
const binaryString = atob(fileBase64);
210+
211+
const len = binaryString.length;
212+
const bytes = new Uint8Array(len);
213+
for (let i = 0; i < len; i += 1) {
214+
bytes[i] = binaryString.charCodeAt(i);
215+
}
216+
217+
const blob = new Blob([bytes], { type: "application/octet-stream" });
210218
const fileName = response.file_name || "file.bin";
211-
fileDownload(fileBuffer, fileName);
219+
220+
fileDownload(blob, fileName);
212221
break;
213222
}
214223
}

frontend/src/containers/list/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,18 @@ export const List: React.FC = () => {
104104
break;
105105
case EActionResponseType.DOWNLOAD_BASE64: {
106106
const fileBase64 = response.data;
107-
const fileBuffer = atob(fileBase64);
107+
const binaryString = atob(fileBase64);
108+
109+
const len = binaryString.length;
110+
const bytes = new Uint8Array(len);
111+
for (let i = 0; i < len; i += 1) {
112+
bytes[i] = binaryString.charCodeAt(i);
113+
}
114+
115+
const blob = new Blob([bytes], { type: "application/octet-stream" });
108116
const fileName = response.file_name || "file.bin";
109-
fileDownload(fileBuffer, fileName);
117+
118+
fileDownload(blob, fileName);
110119
break;
111120
}
112121
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "fastadmin"
3-
version = "0.3.9"
3+
version = "0.3.10"
44
description = "FastAdmin is an easy-to-use Admin Dashboard App for FastAPI/Flask/Django inspired by Django Admin."
55
authors = ["Seva D <vsdudakov@gmail.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)