def create(self, project, object_id, attached_file, **attrs):
        """
        Create a new :class:`Attachment`.

        :param project: :class:`Project` id
        :param object_id: id of the current object
        :param ref: :class:`Task` reference
        :param attached_file: file path that you want to upload
        :param attrs: optional attributes for the :class:`Attachment`
        """
        attrs.update({'project': project, 'object_id': object_id})

        if isinstance(attached_file, file):
            attachment = attached_file
        elif isinstance(attached_file, six.string_types):
            try:
                attachment = open(attached_file, 'rb')
            except IOError:
                raise exceptions.TaigaException(
                    "Attachment must be a IOBase or a path to an existing file"
                )
        else:
            raise exceptions.TaigaException(
                "Attachment must be a IOBase or a path to an existing file"
            )

        return self._new_resource(
            files={'attached_file': attachment},
            payload=attrs
        )
def create ( self , project , object_id , attached_file , ** attrs ) : attrs . update ( { 'project' : project , 'object_id' : object_id } ) if isinstance ( attached_file , file ) : attachment = attached_file elif isinstance ( attached_file , six . string_types ) : try : attachment = open ( attached_file , 'rb' ) except IOError : raise exceptions . TaigaException ( "Attachment must be a IOBase or a path to an existing file" ) else : raise exceptions . TaigaException ( "Attachment must be a IOBase or a path to an existing file" ) return self . _new_resource ( files = { 'attached_file' : attachment } , payload = attrs )
Create a new :class:`Attachment`.

        :param project: :class:`Project` id
        :param object_id: id of the current object
        :param ref: :class:`Task` reference
        :param attached_file: file path that you want to upload
        :param attrs: optional attributes for the :class:`Attachment`