Hi all, for the past few weeks I’ve been trying to create a script that can upload a .rbxm file to Roblox over the endpoint https://data.roblox.com/Data/Upload.ashx however for every example I’ve used to try and build this script with it never seems to work.
This is the function in the script I’ve produced in JavaScript that I’m using for a github actions based uploading system
async function uploadAsset() {
const buffer = fs.readFileSync(`./${process.env.TARGETFILE}`); // This is just the rbxm file
console.debug('Uploading to Roblox...');
let response = await axios
.post(`https://data.roblox.com/Data/Upload.ashx?assetid=${process.env.TARGETASSET}`, buffer, {
timeout: 60 * 3 * 1000, // 3 mins
headers: {
Cookie: `.ROBLOSECURITY=${process.env.ROBLOXCOOKIE}`,
'User-Agent': 'Roblox/WinInet',
'Content-Type': 'application/xml',
Accept: 'application/json',
},
})
.then((d) => d)
.catch((e) => {
console.error(e);
return e;
});
if (response.response.status === 403 && response.response.headers['x-csrf-token']) {
const csrfToken = response.response.headers['x-csrf-token'];
console.debug('Received CSRF challenge, retrying with token...');
response = await axios
.post(`https://data.roblox.com/Data/Upload.ashx?assetid=${process.env.TARGETASSET}`, buffer, {
timeout: 60 * 3 * 1000, // 3 mins
headers: {
'X-CSRF-Token': csrfToken,
Cookie: `.ROBLOSECURITY=${process.env.ROBLOXCOOKIE}`,
'User-Agent': 'Roblox/WinInet',
'Content-Type': 'application/xml',
Accept: 'application/json',
},
})
.then((d) => d)
.catch((e) => {
console.error(e);
return e;
});
}
if (response.response.status >= 200 && response.response.status < 300) {
return;
} else {
throw new Error(`Unable to upload: ${response.status}`);
}
}
However, every time it runs when it attempts to upload a new copy of something it seems to always fail. If anyone could help me fix this script to actually work or inform me on how to properly upload to this endpoint, your help would be appreciated!
Thanks in advance Devforum Community!
Edit: Ive tried publishing the model over Rojo but it doesn’t seem to work.