Gitlab Community Edition Instance
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cdstar
pycdstar3
Commits
cb666a15
Commit
cb666a15
authored
Oct 04, 2019
by
Marcel Hellkamp
Browse files
Added: CDStar.get_file with offset
parent
6da709bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
pycdstar/cdstar.py
View file @
cb666a15
...
...
@@ -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 """
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment