> For the complete documentation index, see [llms.txt](https://docs.yemreak.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yemreak.com/arsiv/programming/uploading-image-to-imgur-with-bunjs.md).

# Uploading image to Imgur with Bunjs

![3820184.png](https://i.imgur.com/nidGOr2.png)

* No need external dependency except `bun-types`

```typescript
export async function uploadToImgur(imageData: ArrayBuffer): Promise<string> {
	const response = await fetch("https://api.imgur.com/3/image", {
		method: "POST",
		body: imageData,
		headers: {
			Authorization: "Client-ID dd32dd3c6aaa9a0",
			"Content-Type": "application/octet-stream"
		}
	})
	if (!response.ok) throw new Error(`Failed to upload image: ${response.statusText}`)

	const responseData = await response.json()
	return responseData.data.link
}

export async function uploadFromPath(imagePath: string): Promise<string> {
	const imageFile = Bun.file(imagePath)
	const imageBytes = await imageFile.arrayBuffer()
	return await uploadToImgur(imageBytes)
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yemreak.com/arsiv/programming/uploading-image-to-imgur-with-bunjs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
