I am looking to save an image in Go, something like this:
url := "http://i.imgur.com/m1UIjW1.jpg"
response, e := http.Get(url)
if e != nil {
log.Fatal(e)
}
defer response.Body.Close()
file, err := os.Create("/tmp/asdf.jpg")
if err != nil {
log.Fatal(err)
}
_, err = io.Copy(file, response.Body)
if err != nil {
log.Fatal(err)
}
file.Close()
However - I am using Blobstore on GAE and all of the examples I find seem to be based on some multi-part form upload based on a users browser...
How do I download an image on GAE/Blobstore with a simple GET request:
func handler(w http.ResponseWriter, r *http.Request) {
urlImage := "http://i.imgur.com/m1UIjW1.jpg"
//when a user calls this root handle, download urlImage to Blobstore
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}