atlassian / atlassian/nucleus

[question] [howto] How to post a file to Nucleus?

Open
#95 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
420
Forks
100
PR merge metrics
No merged PRs in 30d

Description

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:
```

Enter an address for an update server to post to.
This defaults to localhost:3030

Select the folder to upload.

(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);

```

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 the issue; turns out, using Fetch, I wasn't seeing the error being returned by Nucleus, which asked for the version in the file name. The code posted above otherwise works perfectly.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the REST upload endpoint shown in the JavaScript form: /rest/app/{appId}/channel/{channelId}/upload. Review how the request handles the file and returned errors, then document the filename version requirement and the expected successful response so the upload procedure is reproducible.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, electron, javascript
Domain
api, backend, desktop
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.