MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / uploadLogo

Function uploadLogo

src/images.go:9–37  ·  view source on GitHub ↗
(input, filename string)

Source from the content-addressed store, hash-verified

7)
8
9func uploadLogo(input, filename string) (logoURL string, err error) {
10
11 b64data := input[strings.IndexByte(input, ',')+1:]
12
13 // BAse64 in bytes umwandeln un speichern
14 sDec, err := b64.StdEncoding.DecodeString(b64data)
15 if err != nil {
16 return
17 }
18
19 var file = fmt.Sprintf("%s%s", System.Folder.ImagesUpload, filename)
20
21 err = writeByteToFile(file, sDec)
22 if err != nil {
23 return
24 }
25
26 // Respect Force HTTPS setting when generating logo URL
27 if Settings.ForceHttps && Settings.HttpsThreadfinDomain != "" {
28 logoURL = fmt.Sprintf("https://%s:%d/data_images/%s", Settings.HttpsThreadfinDomain, Settings.HttpsPort, filename)
29 } else if Settings.HttpThreadfinDomain != "" {
30 logoURL = fmt.Sprintf("http://%s:%s/data_images/%s", Settings.HttpThreadfinDomain, Settings.Port, filename)
31 } else {
32 logoURL = fmt.Sprintf("%s://%s/data_images/%s", System.ServerProtocol.XML, System.Domain, filename)
33 }
34
35 return
36
37}

Callers 1

WSFunction · 0.70

Calls 1

writeByteToFileFunction · 0.85

Tested by

no test coverage detected