imgbb 通过api上传相册中的图片

问题描述 投票:0回答:2

我在使用 imgbb API 时遇到问题 通过 imgbb API,我一直在尝试将图像上传到我在 imgbb 上创建的相册中。但到目前为止我找不到任何信息...(我已经谷歌搜索了 3 个小时哈哈) 有人知道要添加什么才能将图像保存到相册中吗?

这是我的代码。

感谢您的阅读:)

let body = new FormData()
body.set('key', 'my-api-key')
body.append('image', File)


axios.post('https://api.imgbb.com/1/upload/', body)
    .then((response) => {
        console.log('response', response)
        console.log('response URL', response.data.data.image.url)
        console.log('success')
    })
    .catch((error) => {
        console.log('error', error)
        alert('try agian')
    })  enter code here
node.js reactjs axios
2个回答
0
投票

我也遇到过同样的问题,并且做了一些研究。事实证明,该 API 本身并不支持上传到相册。 如果您需要将图像组织到 ImgBB 上的相册中,通常需要在 ImgBB 网站上或通过其界面手动组织它们。 ImgBB API 主要专注于提供上传图像、检索图像详细信息的端点。 但是,解决方法是在上传图像时对图像描述或元数据中的图像进行分类,然后根据应用程序中的这些类别对它们进行过滤或分组。


-1
投票

来自医生

curl --location --request POST "https://api.imgbb.com/1/upload?expiration=600&key=YOUR_CLIENT_API_KEY" --form "image=R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"

试试这个

let payload = new FormData()
payload.append('image', File)


axios.post('https://api.imgbb.com/1/upload?expiration=600&key=YOUR_CLIENT_API_KEY', payload)
    .then((response) => {
        console.log('response', response)
        console.log('response URL', response.data.data.image.url)
        console.log('success')
    })
    .catch((error) => {
        console.log('error', error)
        alert('try agian')
    }) 
© www.soinside.com 2019 - 2024. All rights reserved.