You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

attachment.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. // Attachment settings
  5. var Attachment = struct {
  6. Storage *Storage
  7. AllowedTypes string
  8. MaxSize int64
  9. MaxFiles int
  10. Enabled bool
  11. }{
  12. Storage: &Storage{},
  13. AllowedTypes: ".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",
  14. MaxSize: 2048,
  15. MaxFiles: 5,
  16. Enabled: true,
  17. }
  18. func loadAttachmentFrom(rootCfg ConfigProvider) (err error) {
  19. sec, _ := rootCfg.GetSection("attachment")
  20. if sec == nil {
  21. Attachment.Storage, err = getStorage(rootCfg, "attachments", "", nil)
  22. return err
  23. }
  24. 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")
  25. Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(2048)
  26. Attachment.MaxFiles = sec.Key("MAX_FILES").MustInt(5)
  27. Attachment.Enabled = sec.Key("ENABLED").MustBool(true)
  28. Attachment.Storage, err = getStorage(rootCfg, "attachments", "", sec)
  29. return err
  30. }