-
Notifications
You must be signed in to change notification settings - Fork 88
/
branding.go
41 lines (34 loc) · 1.01 KB
/
branding.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package handlers
import (
"io/ioutil"
"net/http"
"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/logger"
"github.com/replicatedhq/kots/pkg/store"
)
func (h *Handler) UploadInitialBranding(w http.ResponseWriter, r *http.Request) {
if err := requireValidKOTSToken(w, r); err != nil {
logger.Error(errors.Wrap(err, "failed to validate token"))
return
}
archiveFile, _, err := r.FormFile("brandingArchive")
if err != nil {
logger.Error(errors.Wrap(err, "failed to get form file reader"))
w.WriteHeader(http.StatusInternalServerError)
return
}
defer archiveFile.Close()
brandingArchive, err := ioutil.ReadAll(archiveFile)
if err != nil {
logger.Error(errors.Wrap(err, "failed to read form file"))
w.WriteHeader(http.StatusInternalServerError)
return
}
_, err = store.GetStore().CreateInitialBranding(brandingArchive)
if err != nil {
logger.Error(errors.Wrap(err, "failed to create initial branding"))
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}