Skip to content

deleteitem_internal on media resource, KeyError: 'media' #1484

@zaterio

Description

@zaterio

Environment

  • Python version: Python 3.9.2
  • Eve version: Eve==2.0

EXTENDED_MEDIA_INFO = ['content_type', 'name', 'length']
RETURN_MEDIA_AS_BASE64_STRING = False
RETURN_MEDIA_AS_URL = True
MEDIA_ENDPOINT = 'media'

I'm trying to delete files on the media endpoint, with deleteitem_internal, but apparently deleteitem_internal does not consider the media endpoint when is enabled, the same could be happening for other internal methods. It will also be valuable if when deleting an item from media (with deleteitem_internal), related items in the fs.files and fs.chunks collections are also deleted

Example:

fs.files:

_id: 62fa8c38f4c4954b8fef7e71
filename: "pic.jpg"
contentType: "image/jpg"
chunkSize: 261120
length: 48640
uploadDate: 2022-08-15T18:11:04.278+00:00

fs.chunks:
_id: 62fa8c38f4c4954b8fef7e72
files_id :62fa8c38f4c4954b8fef7e71
n: 0
data: BinData(0, '/9j/4AAQSkZJRgABAgAAAQABAAD//gAQTGF2YzU4LjkxLjEwMAD/2wBDAAgKCgsKCw0NDQ0NDRAPEBAQEBAQEBAQEBASEhIVFRUS…')

media_lookup = {'_id': 62fa8c38f4c4954b8fef7e71 }
deleteitem_internal('media', concurrency_check=False, suppress_callbacks=True, original=None, **media_lookup)

File "/home/trz/pushpull/lib/python3.9/site-packages/eve/methods/delete.py", line 99, in deleteitem_internal
resource_def = config.DOMAIN[resource]
KeyError: 'media'

same error is triggered when trying :
deleteitem_internal('fs.files', concurrency_check=False, suppress_callbacks=True, original=None, **media_lookup)

Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions