Revision f3a722d4
b/.gitignore | ||
---|---|---|
1 | 1 |
*.pyc |
2 | 2 |
*.egg-info |
3 |
*.*.swp |
|
3 | 4 |
_build |
b/kamaki/cli.py | ||
---|---|---|
701 | 701 |
if self.args.container is not None: |
702 | 702 |
self.client.container = self.args.container |
703 | 703 |
|
704 |
@command(api='storage') |
|
705 |
class store_mkdir(_store_container_command): |
|
706 |
"""Create a directory""" |
|
707 |
|
|
708 |
def main(self, path): |
|
709 |
super(store_mkdir, self).main() |
|
710 |
self.client.create_directory(path) |
|
704 | 711 |
|
705 | 712 |
@command(api='storage') |
706 | 713 |
class store_create(_store_account_command): |
b/kamaki/clients/__init__.py | ||
---|---|---|
70 | 70 |
def request(self, method, path, **kwargs): |
71 | 71 |
raw = kwargs.pop('raw', False) |
72 | 72 |
success = kwargs.pop('success', 200) |
73 |
directory = kwargs.pop('directory', False) |
|
73 | 74 |
|
74 | 75 |
data = kwargs.pop('data', None) |
75 | 76 |
headers = kwargs.pop('headers', {}) |
76 | 77 |
headers.setdefault('X-Auth-Token', self.token) |
77 | 78 |
|
78 |
if 'json' in kwargs: |
|
79 |
data = json.dumps(kwargs.pop('json')) |
|
80 |
headers.setdefault('Content-Type', 'application/json') |
|
81 |
|
|
82 |
if data: |
|
83 |
headers.setdefault('Content-Length', str(len(data))) |
|
79 |
if directory: |
|
80 |
headers.setdefault('Content-Type', 'application/directory') |
|
81 |
headers.setdefault('Content-length', '0') |
|
82 |
else: |
|
83 |
if 'json' in kwargs: |
|
84 |
data = json.dumps(kwargs.pop('json')) |
|
85 |
headers.setdefault('Content-Type', 'application/json') |
|
86 |
if data: |
|
87 |
headers.setdefault('Content-Length', str(len(data))) |
|
84 | 88 |
|
85 | 89 |
url = self.base_url + path |
86 | 90 |
kwargs.setdefault('verify', False) # Disable certificate verification |
b/kamaki/clients/storage.py | ||
---|---|---|
82 | 82 |
data = f.read(size) if size is not None else f.read() |
83 | 83 |
self.put(path, data=data, success=201) |
84 | 84 |
|
85 |
def create_directory(self, object): |
|
86 |
self.assert_container() |
|
87 |
path = '/%s/%s/%s' % (self.account, self.container, object) |
|
88 |
self.put(path, data='', directory=True, success=201) |
|
89 |
|
|
85 | 90 |
def get_object(self, object): |
86 | 91 |
self.assert_container() |
87 | 92 |
path = '/%s/%s/%s' % (self.account, self.container, object) |
Also available in: Unified diff