Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreitbart committed Apr 1, 2016
1 parent 10584eb commit 42adbab
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions uploadImage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,6 @@ import (
"strconv"
)

func createUploadForm(image []byte, album string, dtype string, title string, description string) url.Values {
form := url.Values{}

if dtype == "binary" {
form.Add("image", string(image[:]))
form.Add("type", "file")
}
if dtype == "base64" {
form.Add("image", string(image[:]))
form.Add("type", "base64")
}
if dtype == "URL" {
form.Add("image", string(image[:]))
form.Add("type", "URL")
}

if album != "" {
form.Add("album", album)
}
if title != "" {
form.Add("title", title)
}
if description != "" {
form.Add("description", description)
}

return form
}

// UploadImage uploads the image to imgur
// image Can be a binary file, base64 data, or a URL for an image. (up to 10MB)
// album optional The id of the album you want to add the image to.
Expand Down Expand Up @@ -97,3 +68,32 @@ func (client *Client) UploadImage(image []byte, album string, dtype string, titl

return img.Ii, img.Status, nil
}

func createUploadForm(image []byte, album string, dtype string, title string, description string) url.Values {
form := url.Values{}

if dtype == "binary" {
form.Add("image", string(image[:]))
form.Add("type", "file")
}
if dtype == "base64" {
form.Add("image", string(image[:]))
form.Add("type", "base64")
}
if dtype == "URL" {
form.Add("image", string(image[:]))
form.Add("type", "URL")
}

if album != "" {
form.Add("album", album)
}
if title != "" {
form.Add("title", title)
}
if description != "" {
form.Add("description", description)
}

return form
}

0 comments on commit 42adbab

Please sign in to comment.