Cannot upload ePub on issues

  • Gogs Version:
  • System: Ubuntu 18.04.3 LTS
  • Database: MariaDB 10.1.41
  • On my system, when uploading a *.epub file, the upload is accepted but Gogs then a gray X on top of the uploaded file. Hovering over the image says “File type is not allowed”.
  • The same file can be uploaded on a issue.

Originally the upload was forbidden but I modified ALLOWED_TYPES in /etc/gogs/conf/app.ini to image/jpeg|image/png|application/pdf|application/epub+zip then restarted all 3 services (gogs-web-1.service, gogs-web.service, gogs.service). This is the same change I had done previously to support PDF uploads, which worked.

At that point upload appeared to succeed but this error appears. I even rebooted just to be sure I was not missing something, to no avail.

If I click save, the file is just ignored.

Which ALLOWED_TYPES did you modify? Unfortunately, Gogs’s config has 3 allowed types, which could be confusing!

Wonder why do you have 3 services for Gogs?

  • I let the one in [repository.upload] empty, as the comment above says it means any file type
  • I let the one in [release.attachments] at */* as distributed
  • I set the one in [attachments] to image/jpeg|image/png|application/pdf|application/epub+zip

No idea about the services: it is installed by the package. I’ll check what’s in the services. At any given time when gogs works normally (except that issue), systemctl shows:

gogs-web-1.service        loaded active running   gogs-web-1.service
gogs-web.service          loaded active running   gogs-web.service
gogs.service              loaded active running   gogs.service

Would you mind to try */* for this as well? It could be the Dropzone library we use cannot properly recognize application/epub+zip.

Tried this and restarted all three services: this does not fix the issue. The image shows what I see when hovering /after/ the upload.


Regarding the three services:

  • gogs.service
    • wants gogs-web.service
    • ExecStart=/bin/sleep infinity
  • gogs-web.service
    • wants gogs-web-1.service
    • ExecStart=/bin/sleep infinity
  • gogs-web-1.service
    • ExecStart=/usr/bin/gogs run web

I have no idea how it’s ended up with three services.

Would you mind post a link to your test ePub file? So I can try to reproduce myself.

It’s not linked to one epub doc. Try this one, for example:
The same one I generated can be uploaded on the Gogs demo site without issue.

Regarding the services, it seems to work and be updated that way correctly, so I guess that’s the way the build is done. I use the packager build to avoid having to use specific deployment/update procedures.

Actually, I found that adding this application/epub+zip broke /all/ uploads including ones which used to work like application/pdf, not just epub files, so it seems there must be some problematic handling with the “+” symbol. Maybe a split or urldecoding which shouldn’t happen ? And */* does no better.

OK, I did some tests locally.

First of all, use */* definitely works, that’s the value used on and verified working locally.

I also added a log line to print what file type the Go thinks it gets, it turns out to be application/zip.

TL;DR Adding application/epub+zip|application/zip to the end of your ALLOWED_TYPES should solve the problem.

It does indeed fix the issue. Having to allow general zip is only a minor annoyance, so it’s much better that way. So it looks like a parsing bug and a good workaround.

I also found why */* seemed not to work: I had mistakenly typed *.* instead by sheer habit. Actually typing */* works too: I just double-checked.

Thanks a lot for the help.