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
|
|
|
|
|
|
|
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}`
|
|
|
|
}
|
|
|
|
}).then((data) => {
|
|
|
|
return data.json();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-07-10 11:08:23 +07:00
|
|
|
module.exports.create_image = create_image;
|