Gitlab Community Edition Instance

Commit cb666a15 authored by Marcel Hellkamp's avatar Marcel Hellkamp
Browse files

Added: CDStar.get_file with offset

parent 6da709bb
......@@ -156,14 +156,15 @@ class CDStar:
break
def put_file(self, vault, archive, name, source, type=None):
if not hasattr(source, "read"):
raise ValueError("Source must be a file-like object")
if isinstance(source, (str, os.PathLike)):
raise ValueError("Source must be a file-like object, byte string or iterator yielding byte strings.")
return self._rest("PUT", vault, archive, _fix_filename(name), data=source,
headers={'Content-Type': type or "application/x-autodetect"}).json()
def get_file(self, vault, archive, name):
def get_file(self, vault, archive, name, offset=0):
""" Return a stream-able response object representing the requested file. """
return self._rest("GET", vault, archive, _fix_filename(name), stream=True)
headers = {'Range': "bytes={}-".format(offset)} if offset > 0 else {}
return self._rest("GET", vault, archive, _fix_filename(name), stream=True, headers=headers)
def get_fileinfo(self, vault, archive, name, meta=True):
""" Get information about a file """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment