in files/default/rgw_s3_api.py [0:0]
def object_create(bucket, name, string_value=None, file_name_path=None, make_public=False, headers=None, verbose=False):
if not bucket or not name or (string_value is None and file_name_path is None):
if verbose:
print('Bucket handle not valid OR string_value or file_name is empty.')
return None
key = None
try:
key = bucket.get_key(name)
if not key:
key = bucket.new_key(name)
if key:
if string_value:
key.set_contents_from_string(string_value)
if file_name_path:
# Check the size of the file. If it's larger than xxx then do a multipart else do a normal set_content
key.set_contents_from_filename(file_name_path)
if key and make_public:
key.make_public(headers=headers)
if verbose:
print('Object %s created/updated.' % name)
else:
if verbose:
print('Object %s was not created/updated.' % name)
except BaseException, e:
print(e.message)
return key