Gitea: Cannot upload jar file

Created on 20 Jun 2019  路  19Comments  路  Source: go-gitea/gitea

  • Gitea version (or commit ref): 1.8.3
  • Operating system: Ubuntu 18.04
  • Database (use [x]):

    • [ ] PostgreSQL

    • [ x] MySQL

    • [ ] MSSQL

    • [ ] SQLite

  • Can you reproduce the bug at https://try.gitea.io:

    • [ ] Yes (provide example URL)

    • [ ] No

    • [x] Not relevant

  • Log gist:

Description

Despite this setting:
ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

I does not allow upload jar files.
If I set /, then the upload is allowed.

application/* also does not allow me to do that.

What should be the appropriate setting?
...

Screenshots

kinquestion revieweconfirmed

Most helpful comment

I did...

gitea-upload-invalid-type

All 19 comments

_application/java-archive_ not working on Gitea 1.9.0 either

What is the severity of this issue from your perspective?

Where did you upload? Releases or issues?

There are two allowed_types, you may changed the wrong section. I uploaded successfully on my local instance both the releases and issues.

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

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

Where did you upload? Releases or issues?

releases

Hmm, this is interesting.

$ mkdir -p data/tmp/uploads
$ chown ...
$ service gitea restart

And it starts working.
However, after second restart, it stops working, because the tmp directory is gone!
In fact I investigated the following scenarios:

  1. no [repsitory.upload] section in app.ini
    -> no success, even if the directory is created.

  2. [repository.upload]
    ENABLED = true
    TEMP_PATH = data/tmp/uploads
    FILE_MAX_SIZE = 3
    MAX_FILES = 5
    ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

It works after first service restart if the directory is created. It does not work after the second restart, the tmp directory is gone.

  1. [repository.upload]
    ENABLED = true
    TEMP_PATH = /data/gitea/data/tmp/uploads
    FILE_MAX_SIZE = 3
    MAX_FILES = 5
    ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

Directory created, service restarted.
No success

  1. TEMP_PATH = tmp/uploads
    Directory created, service restarted.
    No success

So I got lost, I have no idea

You should try mount tmp as volume in docker

I don't use docker.

Hmm, this is interesting.

$ mkdir -p data/tmp/uploads
$ chown ...
$ service gitea restart

And it starts working.
However, after second restart, it stops working, because the tmp directory is gone!
In fact I investigated the following scenarios:

  1. no [repsitory.upload] section in app.ini
    -> no success, even if the directory is created.

  2. [repository.upload]
    ENABLED = true
    TEMP_PATH = data/tmp/uploads
    FILE_MAX_SIZE = 3
    MAX_FILES = 5
    ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

It works after first service restart if the directory is created. It does not work after the second restart, the tmp directory is gone.

  1. [repository.upload]
    ENABLED = true
    TEMP_PATH = /data/gitea/data/tmp/uploads
    FILE_MAX_SIZE = 3
    MAX_FILES = 5
    ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

Directory created, service restarted.
No success

  1. TEMP_PATH = tmp/uploads
    Directory created, service restarted.
    No success

So I got lost, I have no idea

Is it a bug or do I miss something?

Gitea should support upload of java archive so it must be a configuration or system problem.
To be able to debug, do you have any log of the failed upload ?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

I have the same issue but with .zip files. Can be reproduced on try.giteo.io using a Windows 10 PC and Chrome or Firefox.
It works using iOS! So apparently, mime type is set differently/ incorrectly using Windows 10/ Chrome or Firefox?

2020-01-14 21_09_59-Release aktualisieren - test - Gitea_ Git with a cup of tea - https___try gitea

Yes, It is possible that browser/os use different value. You can debug the mime type in gitea log or with the network inspector on firefox and chrome.
For Chrome: https://developers.google.com/web/tools/chrome-devtools/network#load

There is no activity in the network tab. Possibly the javascript is already blocking the file from being uploaded?

You need to open the network tab before uploading the file

I did...

gitea-upload-invalid-type

It'll be dropzone.js that is blocking the zip directly.

I have also same issue with zip files. It is because of mime-types from code of dropzone.js. Allowed are these image/jpeg,image/png,application/zip,application/gzip and from Win10 with chrome when uploading zip is application/x-zip-compressed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BRMateus2 picture BRMateus2  路  3Comments

cookiengineer picture cookiengineer  路  3Comments

jorise7 picture jorise7  路  3Comments

jakimfett picture jakimfett  路  3Comments

BNolet picture BNolet  路  3Comments