I'm using Atlassian Nucleus and I've been trying to post my electron application release and failing.
I have a local Docker container set up for Nucleus and I can post releases using electron-forge; the files appear, versioned and ready to rock and roll.
I've written a javascript form and I've been attempting to post the release this way as I use electron-packager (electron-forge packages hit just south of a gigabyte while electron-packager prunes to under 300mb).
The form works well enough but I can't seem to post files to Nucleus.
This was my latest iteration:
<form id="release_form">
<label for="server_address">Enter an address for an update server to post to.<br><sup>This defaults to localhost:3030</sup></label>
<input id="server_address" type="text" placeholder="http://localhost:3030" />
<label for="release_package">Select the folder to upload.</label>
<input id="release_package" type="file" />
<input id="submit_release" type="submit" />
</form>
<script>
(function($) {
const release_package = document.getElementById('release_package');
const server_address = document.getElementById('server_address');
const submit_release = document.getElementById('submit_release');
$('#release_form').on('submit', function(e) {
e.preventDefault();
submit_release.disabled = true;
if (release_package.value) {
console.log(release_package.value);
const data = new FormData();
data.append('platform', 'darwin');
data.append('arch', 'x64');
data.append('version', '0.3.0');
let reader = new FileReader();
reader.onload = () => {
data.append(`file`, reader.result);
const config = {
host: (server_address.value) ? server_address.value : 'http://localhost:3030',
appId: '1',
channelId: 'channel_id',
token: 'token'
}
fetch(`${config.host}/rest/app/${config.appId}/channel/${config.channelId}/upload`, {
headers: {
'Authorization': config.token
},
method: 'POST',
body: data,
}).then((response) => {
if (response.status !== 200) {
console.error(`Unexpected response code from Nucleus: ${response.status}`);
}
console.log(response);
}).finally(() => {
submit_release.disabled = false;
});
}
reader.readAsBinaryString(release_package.files[0]);
}
});
})(jQuery);
</script>This iteration comes after several other attempts using various approaches all of which were derived from the suggested example in Electron-Forge's NodeJS publishing code.
The above code results in a 500 error. Attempting to use release_package.files[0] directly results in a 400 error.
Any help would be greatly appreciated.
Edit:
Solved; it turns out, using Fetch, I wasn't seeing the error being returned by Nucleus which specified the filename has to include the version number.
The form works perfectly; it was the filename that was causing issues, hence the 400 error. Once I added the version number to the filename, Nucleus accepted the release package without issue.