file_content is not working as expected? #14651

Closed
opened 2025-11-02 11:19:01 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @rickyma on GitHub (Jun 25, 2025).

Description

By default this API's response only contains file's metadata. Use comma-separated "includes" options to retrieve more fields. Option "file_content" will try to retrieve the file content, option "lfs_metadata" will try to retrieve LFS metadata.

I am using the new API contents-ext. I pass file_content, but the content of the file is still null?
How could I get the content?

lfs_metadata is working fine.

Gitea Version

latest

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

./gitea web

Database

None

Originally created by @rickyma on GitHub (Jun 25, 2025). ### Description ``` By default this API's response only contains file's metadata. Use comma-separated "includes" options to retrieve more fields. Option "file_content" will try to retrieve the file content, option "lfs_metadata" will try to retrieve LFS metadata. ``` I am using the new API `contents-ext`. I pass file_content, but the content of the file is still `null`? How could I get the content? `lfs_metadata` is working fine. ### Gitea Version latest ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? ./gitea web ### Database None
GiteaMirror added the issue/not-a-bug label 2025-11-02 11:19:01 -06:00
Author
Owner

@rickyma commented on GitHub (Jun 25, 2025):

@wxiaoguang PTAL

@rickyma commented on GitHub (Jun 25, 2025): @wxiaoguang PTAL
Author
Owner

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

// summary: The extended "contents" API, to get file metadata and/or content, or list a directory.

file_content only works for "get file metadata and/or content", but not "list a directory"

@wxiaoguang commented on GitHub (Jun 25, 2025): `// summary: The extended "contents" API, to get file metadata and/or content, or list a directory.` `file_content` only works for "get file metadata and/or content", but not "list a directory"
Author
Owner

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

Updated in #34855

	// summary: The extended "contents" API, to get file metadata and/or content, or list a directory.
	// description: It guarantees that only one of the response fields is set if the request succeeds.
	//              Users can pass "includes=file_content" or "includes=lfs_metadata" to retrieve more fields.
	//              "includes=file_content" only works for single file, if you need to retrieve file contents in batch,
	//              use "file-contents" API after listing the directory.
@wxiaoguang commented on GitHub (Jun 25, 2025): Updated in #34855 ``` // summary: The extended "contents" API, to get file metadata and/or content, or list a directory. // description: It guarantees that only one of the response fields is set if the request succeeds. // Users can pass "includes=file_content" or "includes=lfs_metadata" to retrieve more fields. // "includes=file_content" only works for single file, if you need to retrieve file contents in batch, // use "file-contents" API after listing the directory. ```
Author
Owner

@rickyma commented on GitHub (Jun 25, 2025):

OK, so this is an expected behavior.

@rickyma commented on GitHub (Jun 25, 2025): OK, so this is an expected behavior.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14651