Moonbase Documentation

User files examples

Download a user file in multiple languages.

Self-hosted base URL

Use the API base URL

This endpoint returns binary data, so save the response to disk or a blob.

fetch('https://your-moonbase-host/api/user/files/your_file_name', {
method: 'GET',
headers: {
'Authorization': '<PUBLIC_API_KEY>',
'Token': '<jwt_token>'
}
})
.then(response => {
if (!response.ok) throw new Error('Download failed');
return response.blob();
})
.then(blob => {
// Create download link
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'filename.ext';
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
})
.catch(error => console.error('Error:', error));