code.gitea.io/gitea@v1.22.3/modules/setting/attachment.go (about) 1 // Copyright 2020 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package setting 5 6 // Attachment settings 7 var Attachment = struct { 8 Storage *Storage 9 AllowedTypes string 10 MaxSize int64 11 MaxFiles int 12 Enabled bool 13 }{ 14 Storage: &Storage{}, 15 AllowedTypes: ".cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip", 16 MaxSize: 2048, 17 MaxFiles: 5, 18 Enabled: true, 19 } 20 21 func loadAttachmentFrom(rootCfg ConfigProvider) (err error) { 22 sec, _ := rootCfg.GetSection("attachment") 23 if sec == nil { 24 Attachment.Storage, err = getStorage(rootCfg, "attachments", "", nil) 25 return err 26 } 27 28 Attachment.AllowedTypes = sec.Key("ALLOWED_TYPES").MustString(".cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip") 29 Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(2048) 30 Attachment.MaxFiles = sec.Key("MAX_FILES").MustInt(5) 31 Attachment.Enabled = sec.Key("ENABLED").MustBool(true) 32 33 Attachment.Storage, err = getStorage(rootCfg, "attachments", "", sec) 34 return err 35 }