Search code examples
delphifiremonkeyindy

IDHTTPServer: In FireMonkey, how to I serve images from within the app as web images?


IDHTTPServer: In FireMonkey, how to I serve images from within the app as web images?

For example: works with images stored in the filestructure. I don't want to have to save the images to the file structure before serving them. All help appreciated.


Solution

  • You don't need a physical file on the filesystem. In your OnCommand... handler, create an instance of a suitable TStream to hold the image data, like a TMemoryStream, and assign it to the AResponseInfo.ContentStream property. And assign the AResponseInfo.ContentType property to describe the type of data you are sending, like image/png, image/jpeg, etc.