imgbb image uploader
1.0.0
imgbb-image-uploader IMGBB APIに画像をアップロードするための軽量node.jsライブラリです。画像をアップロードして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で大歓迎です。