Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download instead of updating href #8

Open
yamila-fraiman opened this issue Apr 1, 2020 · 0 comments
Open

Download instead of updating href #8

yamila-fraiman opened this issue Apr 1, 2020 · 0 comments

Comments

@yamila-fraiman
Copy link

yamila-fraiman commented Apr 1, 2020

When using allowDownloadByUrl it changes current href instead of downloading a file. It should use same code as the Else content but instead of createObjectURL, use the metadata.

const downloadFile = (item, allowDownloadByUrl) => {
const a = document.createElement('a');
const url = allowDownloadByUrl && item.getMetadata('url') ? item.getMetadata('url') : window.URL.createObjectURL(item.file);
document.body.appendChild(a);
a.style.display = 'none';
a.href = url;
a.download = item.file.name;
a.click();
window.URL.revokeObjectURL(url);
a.remove();
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant