Interface IDynamicWebApi
This interface extends WebAPIs with File-Save helpers. It's important, because if 2sxc also runs on other CMS platforms, then the Dnn Context won't be available, so it's in a separate interface.
Namespace: ToSic.Sxc.WebApi
Assembly: ToSic.Sxc.WebApi.dll
Syntax
[PublicApi_Stable_ForUseInYourCode]
public interface IDynamicWebApi
Methods
| Improve this Doc View SourceFile(String, Nullable<Boolean>, String, String, String, Object)
Create a File-result to stream to the client
Declaration
dynamic File(string noParamOrder = "Params must be named (https://r.2sxc.org/named-params)", bool? download = default(bool? ), string virtualPath = null, string contentType = null, string fileDownloadName = null, object contents = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | noParamOrder | |
System.Nullable<System.Boolean> | download | If a download should be enforced (otherwise the file may just be displayed - like an image) |
System.String | virtualPath | Path in the website to get the file from. Provide either virtualPath or contents |
System.String | contentType | Mime Content-type. Will try to auto-detect from virtualPath or fileDownloadName if not provided. |
System.String | fileDownloadName | Download name. If provided, it will try to force download/save on the browser. |
System.Object | contents | Content of the result - a string, byte[] or stream to include. |
Returns
Type | Description |
---|---|
System.Object |
Remarks
Added in 2sxc 12.05
SaveInAdam(String, Stream, String, String, Nullable<Guid>, String, String)
Save a file from a stream (usually an upload from the browser) into an adam-field of an item. Read more about this in the the WebAPI docs for SaveInAdam
Declaration
IFile SaveInAdam(string noParamOrder = "Params must be named (https://r.2sxc.org/named-params)", Stream stream = null, string fileName = null, string contentType = null, Guid? guid = default(Guid? ), string field = null, string subFolder = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | noParamOrder | |
System.IO.Stream | stream | the stream |
System.String | fileName | file name to save to |
System.String | contentType | content-type of the target item (important for security checks) |
System.Nullable<System.Guid> | guid | |
System.String | field | |
System.String | subFolder |
Returns
Type | Description |
---|---|
IFile |