go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.68k stars 5.46k forks source link

[API] GET ​/repos​/{owner}​/{repo}​/contents​/{filepath} returns null content on big files #14432

Open danielemoroni opened 3 years ago

danielemoroni commented 3 years ago

Description

I uploaded a 14MB file to a repository, and tried the API GET ​/repos​/{owner}​/{repo}​/contents​/{filepath}. Example in try.gitea.io swagger: curl -X GET "https://try.gitea.io/api/v1/repos/danielemoroni/bigfile_test/contents/bigfile.dat" -H "accept: application/json"

I get a response 200 but the content is empty. It's fine if I use the raw api instead, GET /repos/{owner}/{repo}/raw/{filepath}.

Is this a known limit in gitea? I couldn't find any documentation or issue about it.

Screenshots

lunny commented 3 years ago

~It's OK from me.~

image

danielemoroni commented 3 years ago

The response is ok, but content is empty. It's at the end of the first line in your screenshot: "content": ""

For smaller files that field is populated with the file content (as a base64 string).

Incidentally the limit seems to be around 10MB, as I can get a 9.6MB file ok.

6543 commented 3 years ago

I think this is because to convert it into json the whole file is first loaed into mem and then encoded ... to solve this It looks like we have to stream encode it ...?