Move image blobs into separate tables (#618)

* Scene cover fallback to database
* Fix panic if studio not found
* Fix movie studio not being imported/exported
This commit is contained in:
WithoutPants
2020-06-23 09:19:19 +10:00
committed by GitHub
parent f8048dc27c
commit 7a74658a73
31 changed files with 1456 additions and 131 deletions

View File

@@ -1,9 +1,12 @@
package utils
import (
"crypto/md5"
"encoding/base64"
"fmt"
"net/http"
"regexp"
"strings"
)
// ProcessBase64Image transforms a base64 encoded string from a form post and returns the MD5 hash of the data and the
@@ -45,3 +48,18 @@ func GetBase64StringFromData(data []byte) string {
//}
//return result
}
func ServeImage(image []byte, w http.ResponseWriter, r *http.Request) error {
etag := fmt.Sprintf("%x", md5.Sum(image))
if match := r.Header.Get("If-None-Match"); match != "" {
if strings.Contains(match, etag) {
w.WriteHeader(http.StatusNotModified)
return nil
}
}
w.Header().Add("Etag", etag)
_, err := w.Write(image)
return err
}