Files
Marces Zastrow 9c45795e80 Character Creator
Added the character creation page.
2025-01-10 12:05:05 +01:00

34 lines
961 B
JavaScript

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 = 'd7997cfd';
const userId = '1';
const imagePath = './catiana.png';
uploadImage(imagePath, gameId, userId);