code.gitea.io/gitea@v1.19.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
     9  	AllowedTypes string
    10  	MaxSize      int64
    11  	MaxFiles     int
    12  	Enabled      bool
    13  }{
    14  	Storage: Storage{
    15  		ServeDirect: false,
    16  	},
    17  	AllowedTypes: "image/jpeg,image/png,application/zip,application/gzip",
    18  	MaxSize:      4,
    19  	MaxFiles:     5,
    20  	Enabled:      true,
    21  }
    22  
    23  func loadAttachmentFrom(rootCfg ConfigProvider) {
    24  	sec := rootCfg.Section("attachment")
    25  	storageType := sec.Key("STORAGE_TYPE").MustString("")
    26  
    27  	Attachment.Storage = getStorage(rootCfg, "attachments", storageType, sec)
    28  
    29  	Attachment.AllowedTypes = sec.Key("ALLOWED_TYPES").MustString(".csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip")
    30  	Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(4)
    31  	Attachment.MaxFiles = sec.Key("MAX_FILES").MustInt(5)
    32  	Attachment.Enabled = sec.Key("ENABLED").MustBool(true)
    33  }