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

Closed
opened 2025-11-02 07:05:05 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @danielemoroni on GitHub (Jan 22, 2021).

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

Originally created by @danielemoroni on GitHub (Jan 22, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.12.3 and 1.14.0+dev-587-g61f9a72f2 - Git version: - Operating system: <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (https://try.gitea.io/danielemoroni/bigfile_test) - [ ] No - Log gist: <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini --> ## 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 <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the issue/needs-feedbacktype/bugmodifies/api labels 2025-11-02 07:05:05 -06:00
Author
Owner

@lunny commented on GitHub (Jan 25, 2021):

It's OK from me.

image

@lunny commented on GitHub (Jan 25, 2021): ~It's OK from me.~ ![image](https://user-images.githubusercontent.com/81045/105663451-38f92e00-5f0d-11eb-9f11-a937b9286823.png)
Author
Owner

@danielemoroni commented on GitHub (Jan 26, 2021):

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.

@danielemoroni commented on GitHub (Jan 26, 2021): 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.
Author
Owner

@6543 commented on GitHub (Jan 26, 2021):

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 ...?

@6543 commented on GitHub (Jan 26, 2021): 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 ...?
Author
Owner

@wxiaoguang commented on GitHub (Jun 23, 2025):

Could you try 1.24 or main nightly? I think the problem should have been fixed for large files.

Now the response should never be null, only "Encoding" and "Content" fields will be null for large files.

@wxiaoguang commented on GitHub (Jun 23, 2025): Could you try 1.24 or main nightly? I think the problem should have been fixed for large files. Now the response should never be null, only "Encoding" and "Content" fields will be null for large files.
Author
Owner

@GiteaBot commented on GitHub (Jul 24, 2025):

We close issues that need feedback from the author if there were no new comments for a month. 🍵

@GiteaBot commented on GitHub (Jul 24, 2025): We close issues that need feedback from the author if there were no new comments for a month. :tea:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6737