imgbb image uploader
1.0.0
imgbb-image-uploader adalah pustaka Node.js yang ringan untuk mengunggah gambar ke API IMGBB. Ini menyediakan antarmuka yang sederhana dan mudah digunakan untuk mengunggah gambar dan mengambil URL mereka.
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 : Kunci API IMGBB untuk digunakan untuk otentikasi.image : Gambar yang dipilih dari input file.name (Opsional): Nama file gambar. Jika tidak disediakan, nama akan terdeteksi secara otomatis saat mengunggah file dengan multipart/form-data.expiration (opsional): Waktu kedaluwarsa untuk gambar yang diunggah, dalam detik. Gambar yang diunggah akan dihapus secara otomatis setelah waktu ini.Respons ini menampilkan semua informasi yang diunggah gambar dalam format JSON.
JSON Respons akan memiliki kode status header untuk memungkinkan Anda untuk dengan mudah memperhatikan apakah permintaannya baik -baik saja atau tidak. Itu juga akan menghasilkan properti status
{
"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
}Perpustakaan ini dilisensikan di bawah lisensi MIT. Lihat file lisensi untuk detailnya.
Laporan bug dan permintaan tarik dipersilakan di GitHub di https://github.com/sahilverma-dev/imgbb-image-uploader.