gitea: Cannot upload file of this type to a release (zip)

Description

I tried to upload a file to a release but got error message “You cannot upload files of this type”. The file is zip and its mime type is application/zip.

Here is app.ini configuration.

[attachment]
ENABLED = true
PATH = D:/my-work-spaces/gitea/data/attachments
ALLOWED_TYPES = application/zip|application/x-compressed-tar|application/x-gzip
MAX_SIZE = 20
MAX_FILES = 1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 30 (18 by maintainers)

Most upvoted comments

ALLOWED_TYPES = application/zip|application/x-zip|application/x-compressed-tar|application/x-compressed|application/x-gzip|application/x-compress|application/x-zip-compressed|multipart/x-zip

This is work for me. thanks.

I got today the same problem. I tried drag&drop and upload by clicking (file open dialogue).

My parameter are like this:

  • Gitea version: 1.9.1
  • Git version: 2.22.0.windows.1
  • Operating system: (PC A) Windows 7 + Vivaldi 2.6.1566.49 x64 / Firefox 68.0.2 (64-bit) on web version; (PC B) Windows 10 + Vivaldi 2.6.1566.49 x64 on local machine
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:

This setting helped for me:

[attachment]
ENABLED = true
PATH = ./data/attachments
ALLOWED_TYPES = application/zip|application/x-zip|application/x-compressed-tar|application/x-compressed|application/x-gzip|application/x-compress|application/x-zip-compressed|multipart/x-zip
MAX_SIZE = 20
MAX_FILES = 5

TestZipFile.zip

File: TestZipFile.txt Content: This file is test file + new line (CR+LF) Zipped using 7z version 19.00

For release, you should change repository.upload section not attachment

[repository.upload]
ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain"

[attachment]
ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|text/plain"

Same here on latest 1.7.1, it won’t let me upload zip files even though they are explicitly allowed.

Workaround: add application/x-zip-compressed to ALLOWED_TYPES