Would anyone be able to give me a quick pointer as to how I can get an OpenRasta handler that returns a byte array. To be exposed in the ResourceSpace without it being a JSON or XML object. i.e. I don't want it transcoded, I just want to be able to set the media type to "image/PNG" or similar.
Using ASP.Net MVC I can do it using a FileContentResult by returning
File(myByteArray, "image/PNG");
I just need to know the OpenRasta equivalent.
Thanks
You can just return a byte array as part of your handlerm but that will end up being served as application/octet-stream.
If you want to return files, you can simply return an implementation of IFile.
public class MyFileHandler {
public IFile Get(int id) {
var mybytes = new byte[];
return new InMemoryFile(new MemoryStream(mybytes)) {
ContentType = new MediaType("image/png");
}
}
}
You can also set the FileName property to return a specific filename, which will render a Content-Disposition header for you.