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);