This the block of code the grabs and uploads the image
async MediaUpload(photos : any[])
{
const client = await this.Login()
const full_photo_urls : string[] = photos.map((item) => item.full)
let image_ids : string[] = [];
full_photo_urls.forEach(async (image_url) => {
const image_blob = await fetch(image_url).then(res => res.blob())
try {
console.log("images are about to be posted!");
const image_res = await client.postMediaAttachment({file: image_blob})
console.log("Images were posted here"); console.log(image_res); }
catch (error) {
console.error(error);
} }
)
return image_ids;
}
the upload happens and I get status 200, however this does result in a failure and the catch block is ran
Output of error:
{
"failed":true,
"json":{
"id":"111037763715692057",
"type":"image",
"url":"https://files.botsin.space/media_attachments/files/111/037/763/715/692/057/original/c46fd6ce6b892c66.jpeg",
"preview_url":"https://files.botsin.space/media_attachments/files/111/037/763/715/692/057/small/c46fd6ce6b892c66.jpeg",
"remote_url":null,
"preview_remote_url":null,
"text_url":null,
"meta":{
"original":[
"Object"
],
"small":[
"Object"
]
},
"description":null,
"blurhash":"UEHo8yIm%gV?9Exv%fM{?u~qM_D%xvITM{xa"
},
"path":"media",
"response":"Response"{
[
"Symbol(realm)"
]:null,
[
"Symbol(state)"
]:{
"aborted":false,
"rangeRequested":false,
"timingAllowPassed":true,
"requestIncludesCredentials":true,
"type":"default",
"status":200,
"timingInfo":[
"Object"
],
"cacheState":"",
"statusText":"OK",
"headersList":[
"HeadersList"
],
"urlList":[
"Array"
],
"body":[
"Object"
]
},
[
"Symbol(headers)"
]:"HeadersList"{
"cookies":null,
[
"Symbol(headers map)"
]:[
"Map"
],
[
"Symbol(headers map sorted)"
]:null
}
},
"status":200,
"rateLimit":30
}
as you can see the status code is 200 which I would assume mean I can print the result (this is only for testing, usually would get added to image_ids array and than returned)
I am expecting this code to not result in an error and continue running as normally
There was a bug in the TSL Mastodon API that causes an error if a focus point was not provided!