Added a test programm to upload images for characters
This commit is contained in:
Marces Zastrow
2025-01-09 13:19:38 +01:00
parent 779cec4052
commit e498ac886e
354 changed files with 59511 additions and 629 deletions
+34
View File
@@ -0,0 +1,34 @@
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
async function uploadImage(imagePath, gameId, userId) {
try {
// Create form data
const formData = new FormData();
formData.append('image', fs.createReadStream(imagePath));
// Make the request
const response = await axios.put(
`http://localhost:5000/games/${gameId}/${userId}/character/image`,
formData,
{
headers: {
...formData.getHeaders()
}
}
);
console.log('Upload successful:', response.data.message);
} catch (error) {
console.error('Error uploading image:', error.message);
}
}
// Example usage:
// Replace these values with your actual gameId and userId
const gameId = 'eb82723d';
const userId = '1';
const imagePath = './female-char.png';
uploadImage(imagePath, gameId, userId);