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):
        """
        Creates or replaces a storage object in this container.

        The content of the object can either be a stream of bytes (`data`), or
        a file on disk (`file_or_path`). The disk file can be either an open
        file-like object, or an absolute path to the file on disk.

        When creating object from a data stream, you must specify the name of
        the object to be created in the container via the `obj_name` parameter.
        When working with a file, though, if no `obj_name` value is specified,
        the file`s name will be used.

        You may optionally set the `content_type` and `content_encoding`
        parameters; pyrax will create the appropriate headers when the object
        is stored. If no `content_type` is specified, the object storage system
        will make an intelligent guess based on the content of the object.

        If the size of the file is known, it can be passed as `content_length`.

        If you wish for the object to be temporary, specify the time it should
        be stored in seconds in the `ttl` parameter. If this is specified, the
        object will be deleted after that number of seconds.

        If you wish to store a stream of data (i.e., where you don't know the
        total size in advance), set the `chunked` parameter to True, and omit
        the `content_length` and `etag` parameters. This allows the data to be
        streamed to the object in the container without having to be written to
        disk first.
        """
        # First make sure that there is a content source.
        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:
            # Need to wrap the call in a context manager
            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)
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 ) : 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 )
Creates or replaces a storage object in this container.

        The content of the object can either be a stream of bytes (`data`), or
        a file on disk (`file_or_path`). The disk file can be either an open
        file-like object, or an absolute path to the file on disk.

        When creating object from a data stream, you must specify the name of
        the object to be created in the container via the `obj_name` parameter.
        When working with a file, though, if no `obj_name` value is specified,
        the file`s name will be used.

        You may optionally set the `content_type` and `content_encoding`
        parameters; pyrax will create the appropriate headers when the object
        is stored. If no `content_type` is specified, the object storage system
        will make an intelligent guess based on the content of the object.

        If the size of the file is known, it can be passed as `content_length`.

        If you wish for the object to be temporary, specify the time it should
        be stored in seconds in the `ttl` parameter. If this is specified, the
        object will be deleted after that number of seconds.

        If you wish to store a stream of data (i.e., where you don't know the
        total size in advance), set the `chunked` parameter to True, and omit
        the `content_length` and `etag` parameters. This allows the data to be
        streamed to the object in the container without having to be written to
        disk first.