Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
850685bf
Commit
850685bf
authored
Jan 08, 2013
by
Stavros Sachtouris
Browse files
Add store_touch, create_object
Create a zero-length object
parent
8df337ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/commands/pithos_cli.py
View file @
850685bf
...
...
@@ -1256,3 +1256,17 @@ class store_versions(_store_container_command):
t
=
localtime
(
float
(
vitem
[
1
]))
vid
=
bold
(
unicode
(
vitem
[
0
]))
print
(
'
\t
%s
\t
(%s)'
%
(
vid
,
strftime
(
'%d-%m-%Y %H:%M:%S'
,
t
)))
@
command
(
pithos_cmds
)
class
store_touch
(
_store_container_command
):
"""Create an empty file of type application/octet-stream
If object exists, this command will make reset it to 0 length
"""
def
main
(
self
,
container___path
,
content_type
=
'application/octet-stream'
):
super
(
store_touch
,
self
).
main
(
container___path
)
try
:
self
.
client
.
create_object
(
self
.
path
,
content_type
)
except
ClientError
as
err
:
raiseCLIError
(
err
)
kamaki/clients/storage.py
View file @
850685bf
...
...
@@ -159,14 +159,19 @@ class StorageClient(Client):
r
=
self
.
put
(
path
,
data
=
data
,
success
=
201
)
r
.
release
()
def
create_object
(
self
,
obj
):
def
create_object
(
self
,
obj
,
content_type
=
'application/octet-stream'
,
content_length
=
0
):
"""
:param obj: (str) directory-object name
:param content_type: (str) explicitly set content_type
:param content_length: (int) explicitly set content length
"""
self
.
_assert_container
()
path
=
path4url
(
self
.
account
,
self
.
container
,
obj
)
self
.
set_header
(
'Content-Type'
,
'application/directory'
)
self
.
set_header
(
'Content-length'
,
'0'
)
self
.
set_header
(
'Content-Type'
,
content_type
)
self
.
set_header
(
'Content-length'
,
str
(
content_length
)
)
r
=
self
.
put
(
path
,
success
=
201
)
r
.
release
()
...
...
kamaki/clients/tests.py
View file @
850685bf
...
...
@@ -1800,6 +1800,10 @@ class testPithos(unittest.TestCase):
self
.
client
.
container
=
self
.
c2
obj
=
'another.test'
self
.
client
.
create_object
(
obj
+
'.FAKE'
)
r
=
self
.
client
.
get_object_info
(
obj
+
'.FAKE'
)
self
.
assertEqual
(
r
[
'content-type'
],
'application/octet-stream'
)
"""create the object"""
r
=
self
.
client
.
object_put
(
obj
,
data
=
'a'
,
...
...
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