Created
February 13, 2019 11:13
-
-
Save matryer/e154ec06a388da2781b7a3bbcdb8be13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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