I have a lot of images on my website and want to migrate the images to a new hosting. then I made a script to scrape it using xray. once I got the url I want to download the file without writing it to hardisk and then directly upload it to my new hosting.
I am using Strapi and "strapi-provider-upload-wasabi" to upload my image. with my code I always getting 400 Bad request
request.get(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
data = "data:" + response.headers["content-type"] + ";base64," + new Buffer(body).toString('base64');
var form = {
"refId": body.id,
"ref": "comic",
"field": "cover",
"files": data,
"path": "/"
}
request({
uri: 'http://localhost:1337/upload',
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data'
},
formData: form
}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
// console.log(httpResponse);
console.log('Upload successful! Server responded with:', httpResponse.statusMessage);
});
}
});