

def create(self, file_or_path=None, data=None, obj_name=None, content_type=None, etag=None, content_encoding=None, content_length=None, ttl=None, chunked=False, metadata=None, chunk_size=None, headers=None, return_none=False):
    "\n        Creates or replaces a storage object in this container.\n\n        The content of the object can either be a stream of bytes (`data`), or\n        a file on disk (`file_or_path`). The disk file can be either an open\n        file-like object, or an absolute path to the file on disk.\n\n        When creating object from a data stream, you must specify the name of\n        the object to be created in the container via the `obj_name` parameter.\n        When working with a file, though, if no `obj_name` value is specified,\n        the file`s name will be used.\n\n        You may optionally set the `content_type` and `content_encoding`\n        parameters; pyrax will create the appropriate headers when the object\n        is stored. If no `content_type` is specified, the object storage system\n        will make an intelligent guess based on the content of the object.\n\n        If the size of the file is known, it can be passed as `content_length`.\n\n        If you wish for the object to be temporary, specify the time it should\n        be stored in seconds in the `ttl` parameter. If this is specified, the\n        object will be deleted after that number of seconds.\n\n        If you wish to store a stream of data (i.e., where you don't know the\n        total size in advance), set the `chunked` parameter to True, and omit\n        the `content_length` and `etag` parameters. This allows the data to be\n        streamed to the object in the container without having to be written to\n        disk first.\n        "
    if ((data, file_or_path) == (None, None)):
        raise exc.NoContentSpecified('You must specify either a file path, an open file-like object, or a stream of bytes when creating an object.')
    src = (data if data else file_or_path)
    if (src is file_or_path):
        obj_name = _validate_file_or_path(file_or_path, obj_name)
    if (not obj_name):
        raise exc.MissingName('No name for the object to be created has been specified, and none can be inferred from context')
    if chunk_size:
        chunked = True
    if chunked:
        chunk_size = (chunk_size or DEFAULT_CHUNKSIZE)
    headers = (headers or {
        
    })
    if metadata:
        metadata = _massage_metakeys(metadata, OBJECT_META_PREFIX)
        headers = metadata
    if (ttl is not None):
        headers['X-Delete-After'] = ttl
    if (src is data):
        self._upload(obj_name, data, content_type, content_encoding, content_length, etag, chunked, chunk_size, headers)
    elif hasattr(file_or_path, 'read'):
        self._upload(obj_name, file_or_path, content_type, content_encoding, content_length, etag, False, chunk_size, headers)
    else:
        with open(file_or_path, 'rb') as ff:
            self._upload(obj_name, ff, content_type, content_encoding, content_length, etag, False, chunk_size, headers)
    if return_none:
        return
    return self.get(obj_name)

dataset/ETHPy150Open rackspace/pyrax/pyrax/object_storage.py StorageObjectManager.create/original