imgbb image uploader
1.0.0
imgbb-image-uploader ist eine leichte Node.js-Bibliothek zum Hochladen von Bildern in die IMGBB-API. Es bietet eine einfache und benutzerfreundliche Oberfläche zum Hochladen von Bildern und zum Abrufen ihrer URLs.
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 : Der IMGBB -API -Schlüssel zur Authentifizierung.image : Das aus der Dateieingabe ausgewählte Bild.name (optional): Der Name der Bilddatei. Wenn nicht angegeben, wird der Name beim Hochladen einer Datei mit Multipart/Form-Data automatisch erkannt.expiration (optional): Die Ablaufzeit für das hochgeladene Bild in Sekunden. Das hochgeladene Bild wird nach dieser Zeit automatisch gelöscht.Diese Antworten zeigen alle hochgeladenen Informationen im JSON -Format an.
JSON Die Antwort hat Header -Statuscodes, mit denen Sie leicht feststellen können, ob die Anfrage in Ordnung war oder nicht. Es gibt auch die Statuseigenschaften aus
{
"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
}Diese Bibliothek ist unter der MIT -Lizenz lizenziert. Weitere Informationen finden Sie in der Lizenzdatei.
Fehlerberichte und Pull-Anfragen sind auf Github unter https://github.com/sahilverma-dev/imgbb-image-uploader willkommen.