diff options
author | FChannel <> | 2021-06-04 21:44:43 -0700 |
---|---|---|
committer | FChannel <> | 2021-06-04 21:44:43 -0700 |
commit | 84c008bc27510c63fb22d14c8559e05e12953418 (patch) | |
tree | e07de0ead1003e6871c89c3b55e02c01a3567580 /outboxPost.go | |
parent | 8d9218e8cd7f18808bbd6b60e8a489cee967efb4 (diff) |
added exif removal from jpeg, png images
Diffstat (limited to 'outboxPost.go')
-rw-r--r-- | outboxPost.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/outboxPost.go b/outboxPost.go index 5729b2d..ab8c451 100644 --- a/outboxPost.go +++ b/outboxPost.go @@ -10,6 +10,7 @@ import "io/ioutil" import "os" import "regexp" import "strings" +import "os/exec" func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { @@ -31,7 +32,7 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { } contentType, _ := GetFileContentType(f) - + if(!SupportedMIMEType(contentType)) { w.WriteHeader(http.StatusNotAcceptable) w.Write([]byte("file type not supported")) @@ -361,6 +362,18 @@ func ObjectFromForm(r *http.Request, db *sql.DB, obj ObjectBase) ObjectBase { tempFile.Write(fileBytes) + re := regexp.MustCompile(`image/(jpe?g|png|webp)`) + if re.MatchString(obj.Attachment[0].MediaType) { + fileLoc := strings.ReplaceAll(obj.Attachment[0].Href, Domain, "") + + cmd := exec.Command("exiv2", "rm", "." + fileLoc) + + err := cmd.Run() + + CheckError(err, "error with removing exif data from image") + + } + obj.Preview = CreatePreviewObject(obj.Attachment[0]) } |