summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitlab/objects.py9
-rw-r--r--tools/python_test.py1
2 files changed, 10 insertions, 0 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 95e1e45..6e15c3a 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -18,6 +18,7 @@
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
+import base64
import copy
import itertools
import json
@@ -922,6 +923,14 @@ class ProjectFile(GitlabObject):
shortPrintAttr = 'file_path'
getRequiresId = False
+ def decode(self):
+ """Returns the decoded content.
+
+ Returns:
+ (str): the decoded content.
+ """
+ return base64.b64decode(self.content)
+
class ProjectFileManager(BaseManager):
obj_cls = ProjectFile
diff --git a/tools/python_test.py b/tools/python_test.py
index b646116..b1ad953 100644
--- a/tools/python_test.py
+++ b/tools/python_test.py
@@ -110,6 +110,7 @@ readme = admin_project.files.create({'file_path': 'README.rst',
'branch_name': 'master',
'content': 'Initial content',
'commit_message': 'New commit'})
+assert(readme.decode() == 'Initial content')
# labels
label1 = admin_project.labels.create({'name': 'label1', 'color': '#778899'})