Может кто-нибудь помочь мне разобраться, как преобразовать следующий запрос:
curl -F media=@image.jpg <url>
предпочтительно на запрос axios.
Я использовал child_process
Вот пример кода:
const childProcess = require('child_process'); [...] const output = childProcess //filePath is "image.jpg"; url is the link where the image will be uploaded .execSync(`curl -F media=@${filePath} "${url}"`) .toString('utf8'); const response = JSON.parse(output);
Вы ищете что-то вроде этого:
axios.put(url, imageFile, { headers: { 'Content-Type': imageFile.type }); .then(function(response) { //Handle success. }); .catch(function (error) { //Handle errors. });