I have been looking around the topic but couldn’t find it.
I’m looking for a way to retrieve the size of a file whenever a post contains an image (or other type of attachment).
The upload related api has no such ‘get metadata’ function. I can’t use the data explorer because that plugin is not installed.
ask.discourse is indicating that this is a feature gap
You’re correct in identifying a gap in the API. Currently, fetching specific upload attributes (like file size) directly via the REST API is not exposed unless it’s part of the upload response when the file is first uploaded.
Is this correct or am I looking at the wrong location?
I’m part of Exalate - we provide an integration solution allowing to build bridges between various systems. We are currently building an integration allowing to insert the discourse interactions with our own backend system. One of the requirements whenever we provide an attachment on the other side, is that a filesize is provided.
I solved the problem now by getting the file, without streaming it (I hope that it is ok for the discourse backend). The header contains the necessary information such as mimetype and filesize.
It would be nicer to have an explicit REST endpoint, but there is a workaround, so all good.