https://github.com/cmsong111/imgbb-sdk-unofficial
ImaBB Java/Kotlin Unofficial SDK
https://github.com/cmsong111/imgbb-sdk-unofficial
imgbb-api
Last synced: over 1 year ago
JSON representation
ImaBB Java/Kotlin Unofficial SDK
- Host: GitHub
- URL: https://github.com/cmsong111/imgbb-sdk-unofficial
- Owner: cmsong111
- License: apache-2.0
- Created: 2024-08-28T15:27:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-16T15:18:23.000Z (over 1 year ago)
- Last Synced: 2025-03-16T16:23:30.394Z (over 1 year ago)
- Topics: imgbb-api
- Language: Kotlin
- Homepage: https://mvnrepository.com/artifact/io.github.cmsong111/imgbb-unofficial
- Size: 3.82 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ImgBB Unofficial Java SDK
This is an unofficial Java SDK for the [ImgBB](https://imgbb.com) API.
It provides a simple way to interact with the ImgBB API using Java.
## Installation
Add Dependency to your `gradle.build` file:
```gradle
dependencies {
implementation 'io.github.cmsong111:imgbb-unofficial:0.0.4'
}
```
## Usage
### Upload Image File
```kotlin
import io.github.cmsong111.ImgBB
public void example() {
val key = "INPUT_YOUR_API_KEY"
val imageBB = ImgBB(key)
val image = File("path/to/image.jpg")
val result = imageBB.uploadImage(file)
}
```
### Upload Image Bytes (Spring Boot Example)
```kotlin
import io.github.cmsong111.ImgBB
import org.springframework.http.MediaType
@RestController
class ExampleController {
private val imageBB = ImgBB("INPUT_YOUR_API_KEY")
@PostMapping("/upload", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
fun uploadImage(file: MultipartFile): String {
val result = imageBB.uploadImage(
image = file.bytes,
name = file.originalFilename,
expiration = null,
)
return result.url
}
}
```
### Parameters
- `file`: The image file to upload.
- The image file. under 32MB.
- `name`: The name of the image file.
- Use the original file name.
- `expiration`: The time in seconds to keep the image on the server.
- 0 ~ 15552000 (180 days)
- null is not expired.