package main
import (
"fmt"
"log"
"net/http"
"encoding/json"
"google.golang.org/appengine"
"google.golang.org/appengine/blobstore"
)
type Image struct {
Bucket string
Path string
}
func main() {
http.HandleFunc("/serveurl", handle)
log.Print("Listening on port 8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}
func handle(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
image := Image{}
err := json.NewDecoder(r.Body).Decode(&image)
if err != nil{
panic(err)
}
fullPath := fmt.Sprintf("/gs/%s", image.Bucket, image.Path)
fmt.Fprint(w, fullPath)
key, err := blobstore.BlobKeyForFile(ctx, fullPath)
if err != nil {
panic(err)
}
fmt.Fprint(w, key)
}
--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine-go/47d226ae-24ac-48b1-8611-bd233088f3ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.