From f555bfb363779cc6c8f8036f6d6cfa302e15d4fe Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sat, 25 Jun 2022 15:54:10 +0200 Subject: docs(api): document usage of head() methods --- docs/gl_objects/projects.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'docs/gl_objects') diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst index 82a7430..5b0e208 100644 --- a/docs/gl_objects/projects.rst +++ b/docs/gl_objects/projects.rst @@ -380,7 +380,16 @@ Get a file:: # get the decoded content print(f.decode()) - + +Get file details from headers, without fetching its entire content:: + + headers = project.files.head('README.rst', ref='main') + + # Get the file size: + # For a full list of headers returned, see upstream documentation. + # https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository + print(headers["X-Gitlab-Size"]) + Get a raw file:: raw_content = project.files.raw(file_path='README.rst', ref='main') -- cgit v1.2.1