bkk-raindar-misskey/src/api/post.cjs

36 lines
912 B
JavaScript
Raw Normal View History

2024-07-10 11:08:23 +07:00
const axios = require('axios');
2024-07-11 09:47:07 +07:00
const fs = require('fs');
2024-07-10 11:08:23 +07:00
async function create_image(host, access_token, file_path) {
2024-07-11 09:47:07 +07:00
const create = axios.post(`${host}/api/drive/files/create`, {
2024-07-10 11:08:23 +07:00
file: fs.createReadStream(file_path)
}, {
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': `Bearer ${access_token}`
}
});
2024-07-11 09:47:07 +07:00
2024-07-11 11:24:49 +07:00
if(create.status == 200)
2024-07-11 09:47:07 +07:00
return create;
2024-07-10 11:08:23 +07:00
};
2024-07-11 09:47:07 +07:00
async function create_note(host, access_token, text, media_ids, visibility) {
axios.post(`${host}/api/notes/create`, {
text: text,
mediaIds: media_ids,
visibility: visibility
}, {
headers: {
'Authorization': `Bearer ${access_token}`
}
2024-07-11 11:24:49 +07:00
}).then((response) => {
let data = response.data;
return data;
2024-07-11 09:47:07 +07:00
});
}
2024-07-11 11:24:49 +07:00
module.exports.create_image = create_image;
module.exports.create_note = create_note;