gourmet/

directory
v0.0.0-...-85f5b33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2018 License: Apache-2.0

README

Gourmet Project

Resize images from Cloud Storage

Sample code:

package main

import (
	"net/http"
	"strconv"
	"strings"
	"github.com/sfeir-open-source/projects/goroot/src/gourmet/appengine/image"
)

func resizeHandler(w http.ResponseWriter, r *http.Request) {
	split := strings.Split(r.URL.Path[1:], "/")
	if len(split) < 2 {
		return
	}
	bucketName := split[0]
	objectName := split[1]
	width, err := strconv.Atoi(split[2])
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError);
		return
	}

	contents, err := image.ResizeStorageImage(bucketName, objectName, width)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError);
		return
	}

	w.Write(contents)
}

func main() {
	http.HandleFunc("/", resizeHandler)
	http.ListenAndServe(":8080", nil)
}

To preview the image, open up your browser at: http://127.0.0.1:8080//<image-name.png>/250

Directories

Path Synopsis
appengine

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL