MCPcopy Create free account
hub / github.com/golang/appengine / ServingURL

Function ServingURL

image/image.go:30–53  ·  view source on GitHub ↗

ServingURL returns a URL that will serve an image from Blobstore.

(c context.Context, key appengine.BlobKey, opts *ServingURLOptions)

Source from the content-addressed store, hash-verified

28
29// ServingURL returns a URL that will serve an image from Blobstore.
30func ServingURL(c context.Context, key appengine.BlobKey, opts *ServingURLOptions) (*url.URL, error) {
31 req := &pb.ImagesGetUrlBaseRequest{
32 BlobKey: (*string)(&key),
33 }
34 if opts != nil && opts.Secure {
35 req.CreateSecureUrl = &opts.Secure
36 }
37 res := &pb.ImagesGetUrlBaseResponse{}
38 if err := internal.Call(c, "images", "GetUrlBase", req, res); err != nil {
39 return nil, err
40 }
41
42 // The URL may have suffixes added to dynamically resize or crop:
43 // - adding "=s32" will serve the image resized to 32 pixels, preserving the aspect ratio.
44 // - adding "=s32-c" is the same as "=s32" except it will be cropped.
45 u := *res.Url
46 if opts != nil && opts.Size > 0 {
47 u += fmt.Sprintf("=s%d", opts.Size)
48 if opts.Crop {
49 u += "-c"
50 }
51 }
52 return url.Parse(u)
53}
54
55// DeleteServingURL deletes the serving URL for an image.
56func DeleteServingURL(c context.Context, key appengine.BlobKey) error {

Callers

nothing calls this directly

Calls 1

CallFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…