https://www.figma.com/design/xt8O9mFeLl46C5InWwoMrN/Twenty?node-id=36235-120877 Did not do the file manager part. A Function is defined using one unique file at the moment Feature protected by featureFlag `IS_FUNCTION_SETTINGS_ENABLED` ## Demo https://github.com/user-attachments/assets/0acb8291-47b4-4521-a6fa-a88b9198609b
21 lines
609 B
TypeScript
21 lines
609 B
TypeScript
import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';
|
|
|
|
export const downloadFile = (fullPath: string, fileName: string) => {
|
|
fetch(getFileAbsoluteURI(fullPath))
|
|
.then((resp) =>
|
|
resp.status === 200
|
|
? resp.blob()
|
|
: Promise.reject('Failed downloading file'),
|
|
)
|
|
.then((blob) => {
|
|
const url = window.URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.style.display = 'none';
|
|
a.href = url;
|
|
a.download = fileName;
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
window.URL.revokeObjectURL(url);
|
|
});
|
|
};
|