Skip to content

Instantly share code, notes, and snippets.

@matryer
Created February 13, 2019 11:13
Show Gist options
  • Save matryer/e154ec06a388da2781b7a3bbcdb8be13 to your computer and use it in GitHub Desktop.
Save matryer/e154ec06a388da2781b7a3bbcdb8be13 to your computer and use it in GitHub Desktop.
// handleProcess runs the incoming chunk through an exif decoder and
// writes the results to the response.
func handleProcess(w http.ResponseWriter, r *http.Request) {
startOffsetMS, err := strconv.Atoi(r.FormValue("startOffsetMS"))
if err != nil {
http.Error(w, "exif: "+err.Error(), http.StatusBadRequest)
return
}
endOffsetMS, err := strconv.Atoi(r.FormValue("endOffsetMS"))
if err != nil {
http.Error(w, "exif: "+err.Error(), http.StatusBadRequest)
return
}
f, _, err := r.FormFile("chunk")
if err != nil {
http.Error(w, "exif: "+err.Error(), http.StatusBadRequest)
return
}
defer f.Close()
var resp response
resp.Series = []item{{
StartTimeMs: startOffsetMS,
EndTimeMs: endOffsetMS,
}}
x, err := exif.Decode(f)
if err != nil {
resp.Series[0].Vendor.ExifError = err.Error()
}
resp.Series[0].Vendor.Exif = x
if err := json.NewEncoder(w).Encode(resp); err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment