takeSnap
parent
b7da294a17
commit
319bc33d4a
|
@ -5,7 +5,6 @@ const axios = require('axios');
|
|||
|
||||
const UPLOAD_URL = 'https://game-du.teachertrainingkolkata.in/files';
|
||||
const UPDATE_URL = 'https://game-du.teachertrainingkolkata.in/items/game_cross_varient3/1';
|
||||
const DIRECTUS_TOKEN = 'your_directus_token'; // Replace with actual token
|
||||
|
||||
const takeSnap = async (req, res) => {
|
||||
const { url } = req.body;
|
||||
|
@ -32,10 +31,7 @@ const takeSnap = async (req, res) => {
|
|||
formData.append('file', fileBuffer, FILE_PATH);
|
||||
|
||||
const uploadResponse = await axios.post(UPLOAD_URL, formData, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${DIRECTUS_TOKEN}`,
|
||||
...formData.getHeaders()
|
||||
}
|
||||
headers: formData.getHeaders() // No Authorization header
|
||||
});
|
||||
|
||||
if (!uploadResponse.data.data || !uploadResponse.data.data.id) {
|
||||
|
@ -47,10 +43,7 @@ const takeSnap = async (req, res) => {
|
|||
|
||||
// Update Directus Item
|
||||
await axios.patch(UPDATE_URL, { thumbnail: fileId }, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${DIRECTUS_TOKEN}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
headers: { 'Content-Type': 'application/json' } // No Authorization header
|
||||
});
|
||||
|
||||
console.log('Directus item updated successfully');
|
||||
|
|
Loading…
Reference in New Issue