MVC GetImage
No edit summary
No edit summary
 
(19 intermediate revisions by 4 users not shown)
Line 1: Line 1:
MVC we have a controller GetImage that expects a object identity and a attribute with a blob, like this: <nowiki>http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage</nowiki>
<message>Write the content here to display this box</message>
With MVC, we have a controller <code><span class="col-black">'''GetImage'''</span></code> that expects an object identity and an attribute with a Blob, like this: http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage  


You may append yet another section with '-' that denotes contenttype header to send to browser:
You may append yet another section with <code><span class="col-black">'''<nowiki/>'-''''</span></code> that denotes a content-type header to send to the browser:


<nowiki>http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage-application%2Fpdf</nowiki> will use application/pdf as content type.
http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage-application%2Fpdf will use application/pdf as the content type.
 
'''NEW:''' Starting from 2023-08-31 yet another parameter with '''<nowiki/>'-'''' (forth) will set the content-disposition filename.
 
This controller may be used by Angular views as well if you want to construct a link to download a file or something without actually having the attribute loaded (if it is marked as delayed fetch).
 
==== '''Option 1''' ====
Now you can return Text content this way too.
 
==== '''Option 2''' ====
For security concerns, use the <code><span class="col-black">'''AllowMVCAccess'''</span></code> tagged value on the attribute. This is the default "ok" for byte[] (to be backward compatible) and the default "notok" for strings - you can also set "okwhenauthenticated". No accessgroup evaluation is provided for GetImage.
 
See also [[Documentation:The ExternalId explained|The_ExternalId_explained]] to create a more long-lived link.
[[Category:MVC]]
{{Edited|July|12|2025}}

Latest revision as of 05:28, 25 February 2025

This page was created by Hans.karlsen@mdriven.net on 2019-08-06. Last edited by Stephanie@mdriven.net on 2025-02-25.

With MVC, we have a controller GetImage that expects an object identity and an attribute with a Blob, like this: http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage

You may append yet another section with '-' that denotes a content-type header to send to the browser:

http://localhost:5052/Turnkey/GetImage?img=9!10-SomeImage-application%2Fpdf will use application/pdf as the content type.

NEW: Starting from 2023-08-31 yet another parameter with '-' (forth) will set the content-disposition filename.

This controller may be used by Angular views as well if you want to construct a link to download a file or something without actually having the attribute loaded (if it is marked as delayed fetch).

Option 1

Now you can return Text content this way too.

Option 2

For security concerns, use the AllowMVCAccess tagged value on the attribute. This is the default "ok" for byte[] (to be backward compatible) and the default "notok" for strings - you can also set "okwhenauthenticated". No accessgroup evaluation is provided for GetImage.

See also The_ExternalId_explained to create a more long-lived link.