const axios = require('axios');
const fs = require('fs');
// Define the API endpoint and the API key
const API_LINK = 'https://api.getvalenceai.com/emotionprediction';
const API_KEY = 'YOUR_API_KEY';
// Define the file path to upload
const filePath = "YOUR_FILE";
// Open the file and prepare the request
const file = fs.createReadStream(filePath);
const formData = new FormData();
formData.append('file', file);
// Prepare the headers with the API key
const headers = {
'x-api-key': API_KEY,
...formData.getHeaders()
};
// Make the POST request to upload the file
axios.post(API_LINK, formData, { headers })
.then(response => {
console.log("Response:", response.data);
})
.catch(error => {
console.error(`Failed to upload file, ${error.response.status}, ${error.response.data}`);
});