gpt4 book ai didi

I am using the TSL Mastodon API, I wrote a simple function to grab images from a url and upload them to Mastodon but getting unexpected results(我正在使用TSL Mastodon API,我编写了一个简单的函数来从URL获取图像并将它们上传到Mastodon,但得到了意想不到的结果)

转载 作者:bug小助手 更新时间:2023-10-25 23:31:55 24 4
gpt4 key购买 nike



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

上载发生了,我得到了状态200,但是这确实会导致失败,并且CATCH块被运行


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)

正如您所看到的,状态代码是200,我认为这意味着我可以打印结果(这只是为了测试,通常会添加到IMAGE_ID数组中,然后返回)


I am expecting this code to not result in an error and continue running as normally

我希望这段代码不会导致错误,并继续正常运行


更多回答

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.

请澄清您的具体问题或提供更多详细信息,以突出您的确切需求。按照目前的写法,很难准确地说出你在问什么。

This was resolved and was due to a bug in the TSL Mastodon API.

此问题已得到解决,原因是TSL Mastodon API中存在错误。

优秀答案推荐

There was a bug in the TSL Mastodon API that causes an error if a focus point was not provided!

TSL Mastodon API中有一个错误,如果没有提供焦点就会导致错误!


更多回答

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

您的答案可以通过其他支持信息来改进。请编辑以添加更多详细信息,如引用或文档,以便其他人可以确认您的答案是正确的。你可以在帮助中心找到更多关于如何写出好答案的信息。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com