upload image to Gyazo from golang
- create your own application from https://gyazo.com/oauth/applications.
- get access token from application setting or use
gyazo.AuthorizeByHTTP
or oauth2
accessToken := "xxx"
imageReader, err := os.Open("nana.png")
if err != nil {
panic(err)
}
client := gyazo.NewOauth2Client(accessToken)
result, err := client.Upload(imageReader, nil)
fmt.Printf("image_id: %s\npermalink: %s\nthumbnail: %s\nurl: %s\ntype: %s\ncreated_at %s",
result.ImageID, // 0123456789abcdef0123456789abcdef
result.PermalinkURL, // https://gyazo.com/0123456789abcdef0123456789abcdef
result.ThumbURL, // https://thumb.gyazo.com/thumb/200/...
result.URL, // https://i.gyazo.com/0123456789abcdef0123456789abcdef.png
result.Type, // png
result.CreatedAt, // 2038-01-19T03:14:07+0000
)
uploader := gyazo.NewDIDUploader("")
result, err := uploader.Upload(imageReader, nil)
if err != nil {
panic(err)
}
fmt.Println(result.PermalinkURL) // https://gyazo.com/0123456789abcdef0123456789abcdef
fmt.Println(result.DeviceID) // 0123456789abcdef0123456789abcdef
Note: keep your device id a secret, it is like your Gyazo password
Your device id is stored at %appdata%\Gyazo\id.txt
on Windows.
uploader := gyazo.NewDIDUploader(yourDeviceID)
This uploader uploads to your Gyazo account.