imgbb image uploader
1.0.0
imgbb-image-uploader是一个轻巧的节点。JS库,用于将图像上传到IMGBB API。它提供了一个简单易用的界面,用于上传图像和检索其URL。
https://imgbb.com/
https://api.imgbb.com/
npm install imgbb-image-uploader import { imgbbUpload } from "imgbb-image-uploader" ;
imgbbUpload ( {
key : "your-api-key" , // your imgbb api key
image : image , // image selected from the file input
} )
. then ( ( data ) => {
console . log ( "Image uploaded to ImgBB:" , data ) ;
} )
. catch ( ( error ) => {
console . error ( "Failed to upload image to ImgBB:" , error ) ;
} ) ; import imgbbUpload from "imgbb-image-uploader" ;
// Upload an image to ImgBB with additional options
imgbbUpload ( {
key : "your-api-key" , // your imgbb api key
image : image , // image selected from the file input
expiration : 600 , // 10 mins
name : "name-of-the-image" , // name of the image
} )
. then ( ( data ) => {
console . log ( "Image uploaded to ImgBB:" , data ) ;
} )
. catch ( ( error ) => {
console . error ( "Failed to upload image to ImgBB:" , error ) ;
} ) ;key :用于身份验证的IMGBB API密钥。image :从文件输入中选择的图像。name (可选):图像文件的名称。如果未提供,则在用Multipart/form-data上传文件时将自动检测到该名称。expiration (可选):上载图像的到期时间,以秒为单位。这段时间后将自动删除上传的图像。此响应以JSON格式显示所有图像上传信息。
JSON响应将具有标头状态代码,以使您可以轻松注意到请求是否可以。它还将输出状态属性
{
"data" : {
"id" : " 2ndCYJK " ,
"title" : " c1f64245afb2 " ,
"url_viewer" : " https://ibb.co/2ndCYJK " ,
"url" : " https://i.ibb.co/w04Prt6/c1f64245afb2.gif " ,
"display_url" : " https://i.ibb.co/98W13PY/c1f64245afb2.gif " ,
"width" : " 1 " ,
"height" : " 1 " ,
"size" : " 42 " ,
"time" : " 1552042565 " ,
"expiration" : " 0 " ,
"image" : {
"filename" : " c1f64245afb2.gif " ,
"name" : " c1f64245afb2 " ,
"mime" : " image/gif " ,
"extension" : " gif " ,
"url" : " https://i.ibb.co/w04Prt6/c1f64245afb2.gif "
},
"thumb" : {
"filename" : " c1f64245afb2.gif " ,
"name" : " c1f64245afb2 " ,
"mime" : " image/gif " ,
"extension" : " gif " ,
"url" : " https://i.ibb.co/2ndCYJK/c1f64245afb2.gif "
},
"medium" : {
"filename" : " c1f64245afb2.gif " ,
"name" : " c1f64245afb2 " ,
"mime" : " image/gif " ,
"extension" : " gif " ,
"url" : " https://i.ibb.co/98W13PY/c1f64245afb2.gif "
},
"delete_url" : " https://ibb.co/2ndCYJK/670a7e48ddcb85ac340c717a41047e5c "
},
"success" : true ,
"status" : 200
}该图书馆已获得MIT许可证的许可。有关详细信息,请参见许可证文件。
欢迎在https://github.com/sahilverma-dev/imgbb-image-uploader上的GitHub上的错误报告和拉动请求。