RocketCDS
Installation
Integration
RocketCDS
Installation
Integration
Installing AppThemes
Partial And Shared Templates
Razor Tokens
Dependancy
JQuery Validation
DNN Search
File Download
Rocket Tools
ChatGPT
DeepL
Simplisity JS
Command Attributes
Methods
Class Events
Field Data
Utility Functions
Ajax DropDownList
RocketContent
Create an AppTheme
Adding CSS and JS
Adding Resx
Multi-Row AppTheme
DataObjects
Razor Tokens
Shared Templates
Snippets
ArticleLimpet
ArticleRowLimpet
RocketDirectory
Create an AppTheme
DataObjects
Razor Tokens
Shared Templates
MenuManipulator
Category Menu
Text Search
Property Filter
Tag Filter
Secure Document
Snippets
RSS feed
Related Articles
ArticleLimpet
RocketForms
Create an AppTheme
DataObjects
Functionality
Module Settings
# File Download ## Simple public download Documents can be downloaded by using a simple html link or javascript. The same as in any webpage. HTML ```
Download Brochure
``` JS ``` ``` ### RocketDirectoryAPI File downloads from RocketDirectory have a default document field name. (But any field name can be used n the template) ``` @foreach (var doc in articleData.GetDocs()) {
@doc.Name
} ``` ## Restricted download Simplsity.js can download files from an API call. This allows server side tests to check if the users has security access to download. Example: ``` @foreach (var doc in articleData.GetDocs()) {
@doc.Name
} ``` The simplsity class event of "simplisity_filedownload" creates a URL to download from the API. *NOTE: This example is from RocketDirectory and must include "articleid" and "dockey".* ## Important To make Simplisity file downloads work, you MUST implement the link within a html element within a “simplisity_panel” class. Activate simplisity by the JS call to “StartUp” or a “single panel”. ``` $(document).simplisityStartUp('/Desktopmodules/dnnrocket/api/rocket/action', { "systemkey": "rocketdirectoryapi"}); ``` # Server Side Because the s-fields are added to the url as parameters you can therefore access those values on server-side code by using the “genxml/urlparams/***” xpath from the paramInfo SimplsityInfo class. ## Return dictionary keys on server code The download can be done from a file or from a document in memory. ### From File ``` rtnDic.Add("filenamepath", DNNrocketUtils.MapPath(articleDoc.RelPath)); rtnDic.Add("downloadname", articleDoc.Name); ``` ### From Memory Data (Recommended with only small files [< 10MB], but may work with larger files if the server is powerful) ``` rtnDic.Add("downloadfiledata", "String Data"); rtnDic.Add("downloadname", articleDoc.Name); ``` # RocketDirectory The default server side code in RocketDirectory checks is the user is authorised. If not, no download is done. This functionality is controlled by the "secure documents" checkbox in the Admin Settings for the system. Uploads will be given a secure name that cannot be downloaded by normal html links. (This assumes the IIS default settings for files.) This functionlity stops and documents from being referenced by any search engine. *NOTE: The "secure document" must be turned on before upload if you required secure documents.* If public downloads are required for the entire site, you can uncheck the "secure documents" checkbox. You must use a **s-cmd="remote_publicdownload"** to get this functionality. If extra security is required then a plugin will need to be created. Example: ``` private Dictionary
DownloadArticleFile() { var rtnDic = new Dictionary
(); var strId = GeneralUtils.DeCode(_paramInfo.GetXmlProperty("genxml/urlparams/articleid")); var articleId = 0; if (GeneralUtils.IsNumeric(strId) && (UserUtils.IsAuthorised() || !_dataObject.PortalContent.SecureUpload)) { articleId = Convert.ToInt32(strId); var articleData = GetActiveArticle(articleId); articleData.ClearCache(); // reset data to clear cached name. articleData = GetActiveArticle(articleId); var dockey = GeneralUtils.DeCode(_paramInfo.GetXmlProperty("genxml/urlparams/dockey")); var articleDoc = articleData.GetDoc(dockey); rtnDic.Add("filenamepath", DNNrocketUtils.MapPath(articleDoc.RelPath)); rtnDic.Add("downloadname", articleDoc.DownloadName); } return rtnDic; } ``` ## InterfaceKey An interfacekey must also exist in the "system.rules" file. The interfacekey name must match the command. Usually "remote", for public access with the security being done server side o the download API method. Example: ```
remote
RocketDirectoryAPI.API.StartConnect
RocketDirectoryAPI
/DesktopModules/DNNrocketModules/RocketDirectoryAPI
false
true
1
1
1
1
1
1
1
```