imgbb image uploader
1.0.0
imgbb-image-uploader é uma biblioteca leve Node.js para fazer upload de imagens para a API IMGBB. Ele fornece uma interface simples e fácil de usar para fazer upload de imagens e recuperar seus 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 : a chave da API do IMGBB a ser usada para autenticação.image : a imagem selecionada na entrada do arquivo.name (Opcional): o nome do arquivo de imagem. Se não for fornecido, o nome será detectado automaticamente ao fazer upload de um arquivo com multipart/formulário.expiration (opcional): o tempo de expiração para a imagem carregada, em segundos. A imagem carregada será excluída automaticamente após esse período.Essas respostas exibem todas as informações da imagem no formato JSON.
JSON A resposta terá códigos de status dos cabeçalhos para permitir que você observe facilmente se a solicitação estava bem ou não. Também produzirá as propriedades de 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
}Esta biblioteca está licenciada sob a licença do MIT. Consulte o arquivo de licença para obter detalhes.
Relatórios de bug e solicitações de puxar são bem-vindos no github em https://github.com/sahilverma-dev/imgb-image-uploader.