Commit 17428e1a authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'develop' into feature-output

parents 83c3ba87 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)
......@@ -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()
......
......@@ -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',
......
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