Storage from_path storing and downloading a file

Hey there!

The download parameter only works when downloading files on the same origin, which might be causing your code to not work as expected (<a>: The Anchor element - HTML: HyperText Markup Language | MDN).

To get around this, you could try downloading the file as a blob first using a fetch GET request, then triggering a download by using URL.createObjectURL and a dummy anchor element that you trigger a click on via JS.

Something like (not tested):

async function downloadFile(url) {
	const response = await fetch(url);
	const blob = response.blob();
	const href = URL.createObjectURL(blob);
	
	const a = document.createElement('a');
	a.href = href;
	a.download = 'your-filename.ifc';
	a.click();
	
	// at some point after the click you should clean up memory by using: URL.revokeObjectURL(a.href);
}
1 Like