2020-07-19 12:10:45 +00:00
|
|
|
# teal
|
2020-07-19 12:58:32 +00:00
|
|
|
[![godoc](https://img.shields.io/badge/Documentation-godoc-%23009999)](https://godoc.org/gitea.com/webb/teal) [![pkg.go.dev](https://img.shields.io/badge/Documentation-go.pkg.dev-%23009999)](https://pkg.go.dev/gitea.com/webb/teal)
|
2020-07-19 12:10:45 +00:00
|
|
|
|
|
|
|
This is a simple library for pxl.blue, an image hosting site. Consider this library extremely unstable
|
|
|
|
as pxl.blue and this library are still very early in development.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2020-07-19 17:24:25 +00:00
|
|
|
### Logging in, and uploading a file
|
|
|
|
|
2020-07-19 12:10:45 +00:00
|
|
|
```
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-07-19 12:13:24 +00:00
|
|
|
"os"
|
2020-07-19 12:10:45 +00:00
|
|
|
"gitea.com/webb/teal"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
client, _ := teal.Login("username", "password")
|
|
|
|
file, _ := os.Open("glenda.png")
|
|
|
|
image, _ := client.UploadFile(file, "glenda.png")
|
|
|
|
fmt.Println(image)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Getting an upload key with username and password
|
2020-07-19 17:24:25 +00:00
|
|
|
|
2020-07-19 12:10:45 +00:00
|
|
|
```
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"gitea.com/webb/teal"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
client, _ := teal.Login("username", "password")
|
|
|
|
fmt.Println(client.UploadKey)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Manually creating a barebones client and uploading a file
|
|
|
|
|
|
|
|
```
|
|
|
|
import (
|
2020-07-19 12:13:24 +00:00
|
|
|
"fmt"
|
2020-07-19 12:16:01 +00:00
|
|
|
"os"
|
2020-07-19 12:13:24 +00:00
|
|
|
"gitea.com/webb/teal"
|
2020-07-19 12:10:45 +00:00
|
|
|
)
|
2020-07-19 12:16:01 +00:00
|
|
|
|
2020-07-19 12:10:45 +00:00
|
|
|
func main() {
|
2020-07-19 12:13:24 +00:00
|
|
|
client := teal.Client{
|
2020-07-19 12:16:01 +00:00
|
|
|
UserAgent: "teal",
|
|
|
|
UploadKey: "key",
|
2020-07-19 12:13:24 +00:00
|
|
|
}
|
2020-07-19 12:16:01 +00:00
|
|
|
|
2020-07-19 12:13:24 +00:00
|
|
|
file, _ := os.Open("glenda.png")
|
|
|
|
url, _ := client.UploadFile(file, "glenda.png")
|
|
|
|
fmt.Println(url)
|
|
|
|
}
|
2020-07-19 12:10:45 +00:00
|
|
|
```
|