'* POST /api/folders/{encoded_id}/contents
create a new library file from an HDA
:param  encoded_folder_id:      the encoded id of the folder to import dataset(s) to
:type   encoded_folder_id:      an encoded id string
:param  payload:    dictionary structure containing:
:param from_hda_id:         (optional) the id of an accessible HDA to copy into the library
:type  from_hda_id:         encoded id
:param from_hdca_id:         (optional) the id of an accessible HDCA to copy into the library
:type  from_hdca_id:         encoded id
:param ldda_message:        (optional) the new message attribute of the LDDA created
:type   ldda_message:       str
:param extended_metadata:   (optional) dub-dictionary containing any extended metadata to associate with the item
:type  extended_metadata:   dict
:type   payload:    dict
:returns:   a dictionary describing the new item if ``from_hda_id`` is supplied or a list of
such dictionaries describing the new items if ``from_hdca_id`` is supplied.
:rtype:     object
:raises:    ObjectAttributeInvalidException,
InsufficientPermissionsException, ItemAccessibilityException,
InternalServerError'

@expose_api
def create(self, trans, encoded_folder_id, payload, **kwd):

    encoded_folder_id_16 = self.__decode_library_content_id(trans, encoded_folder_id)
    from_hda_id = payload.pop('from_hda_id', None)
    from_hdca_id = payload.pop('from_hdca_id', None)
    ldda_message = payload.pop('ldda_message', '')
    if ldda_message:
        ldda_message = util.sanitize_html.sanitize_html(ldda_message, 'utf-8')
    try:
        if from_hda_id:
            decoded_hda_id = self.decode_id(from_hda_id)
            return self._copy_hda_to_library_folder(trans, self.hda_manager, decoded_hda_id, encoded_folder_id_16, ldda_message)
        if from_hdca_id:
            decoded_hdca_id = self.decode_id(from_hdca_id)
            return self._copy_hdca_to_library_folder(trans, self.hda_manager, decoded_hdca_id, encoded_folder_id_16, ldda_message)
    except Exception as exc:
        if (('not    accessible    to    the    current    user' in str(exc)) or ('You    are    not    allowed    to    access    this    dataset' in str(exc))):
            raise exceptions.ItemAccessibilityException('You    do    not    have    access    to    the    requested    item')
        else:
            log.exception(exc)
            raise exc
