Revolt API: How to upload user avatar #633
Unanswered
DezyNation
asked this question in
Q&A
Replies: 1 comment
-
You can generate any attachment ID if you upload a formdata to autumn. Example using Node.js: const AUTUMN = 'https://autumn.revolt.chat'
async function uploadFile(tag, buf){
const formData = new FormData();
formData.set("file", new Blob([buf]));
const res = await fetch(`${AUTUMN}/${tag}`, {
method: 'POST',
body: formData,
}).then(res=>res.json());
return res.id
}
const file = fs.readFileSync('bun.gif');
uploadFile('avatars', file)
.then(id=>console.log(`Attachment ID is ${id}`))
.catch(e=>console.error(e)); Edit: ID is generated but GET requests using those IDs seem to fail 🤔 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The official API documentation has mentioned a
PATCH
request to update the user. But I don't know how to upload the user's avatar.The documentation asks for an attachment ID in the
avatar
field but how do we generate that attachment ID? Is there any API available to upload files through autumn?Beta Was this translation helpful? Give feedback.
All reactions