diff --git a/packages/strapi-plugin-upload/admin/src/components/EditForm/index.js b/packages/strapi-plugin-upload/admin/src/components/EditForm/index.js
index 03b8eed37d..4ba98d88ea 100644
--- a/packages/strapi-plugin-upload/admin/src/components/EditForm/index.js
+++ b/packages/strapi-plugin-upload/admin/src/components/EditForm/index.js
@@ -1,3 +1,4 @@
+/* eslint-disable jsx-a11y/anchor-is-valid */
/* eslint-disable react/jsx-fragments */
import React, {
Fragment,
@@ -8,6 +9,7 @@ import React, {
useImperativeHandle,
} from 'react';
import { CopyToClipboard } from 'react-copy-to-clipboard';
+import axios from 'axios';
import { get } from 'lodash';
import PropTypes from 'prop-types';
import { Inputs } from '@buffetjs/custom';
@@ -205,7 +207,22 @@ const EditForm = forwardRef(
};
const handleClickDownload = () => {
- aRef.current.click();
+ axios
+ .get(prefixedFileURL, {
+ headers: new Headers({ Origin: window.location.origin, mode: 'cors' }),
+ responseType: 'blob',
+ })
+ .then(({ data }) => {
+ const blobUrl = URL.createObjectURL(data);
+
+ aRef.current.download = downloadFileName;
+ aRef.current.href = blobUrl;
+
+ aRef.current.click();
+ })
+ .catch(err => {
+ console.error(err);
+ });
};
const handleSubmit = e => {
@@ -242,17 +259,14 @@ const EditForm = forwardRef(
type="download"
onClick={handleClickDownload}
/>
- {isFileDownloadable && (
-
- hidden
-
- )}
+
+ hidden
+
+