imgbb image uploader
1.0.0
imgbb-image-uploader เป็นไลบรารี Node.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-dataexpiration (ไม่บังคับ): เวลาหมดอายุสำหรับภาพที่อัปโหลดเป็นวินาที ภาพที่อัปโหลดจะถูกลบโดยอัตโนมัติหลังจากเวลานี้คำตอบนี้แสดงข้อมูลที่อัปโหลดรูปภาพทั้งหมดในรูปแบบ 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 ดูไฟล์ใบอนุญาตสำหรับรายละเอียด
รายงานข้อผิดพลาดและคำขอดึงยินดีต้อนรับบน GitHub ที่ https://github.com/sahilverma-dev/imgbb-image-uploader