<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Interacting With Files</title><link>https://community.telligent.com/community/11/w/developer-training/65118/interacting-with-files</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>Interacting With Files</title><link>https://community.telligent.com/community/11/w/developer-training/65118/interacting-with-files</link><pubDate>Tue, 04 Aug 2020 21:54:44 GMT</pubDate><guid isPermaLink="false">fe260e91-80e1-4a86-92e5-5b9541087337</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65118/interacting-with-files#comments</comments><description>Current Revision posted to Developer Training by Former Member on 08/04/2020 21:54:44&lt;br /&gt;
&lt;p&gt;The Verint Community platform provides support for creating file stores within the [[Centralized File Storage|Centralized File Storage System]] to enable plugins to store, secure, serve, and generate files.&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2&gt;&lt;a id="Why_Would_I_Create_a_File_Store" name="Why_Would_I_Create_a_File_Store"&gt;&lt;/a&gt;Why Would I Create a File Store?&lt;/h2&gt;
&lt;p&gt;A file store is a unique set of paths and files located within the [[Centralized File Storage|Centralized File Storage System (CFS)]].&amp;nbsp;Each file store is a self-contained set of files that can be independently secured and located on the storage provider (operating system file system, Amazon S3, etc) of choice.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When implementing a [[Plugins|plugin]] that needs to store files, it is best to store those files in the [[Centralized File Storage|CFS]] within a file store that you maintain. It is not advised to reuse an existing file store.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_a_File_Store" name="Creating_a_File_Store"&gt;&lt;/a&gt;Creating a File Store&lt;/h2&gt;
&lt;p&gt;Creating a new file store within the [[Centralized File Storage|CFS]] requires implementing the [[api-documentation:ICentralizedFileStore Plugin Type|ICentralizedFileStore]] [[Plugins|plugin]] type. &lt;code&gt;ICentralizedFileStore&lt;/code&gt; adds only a single member to [[api-documentation:IPlugin Plugin Type|IPlugin]], the programmatic name of the file store. The name must be unique and must meet the naming guidelines of the [[Centralized File Storage|CFS]].&lt;/p&gt;
&lt;p&gt;As a sample, the is the full implementation of a sample file store with the key &amp;quot;sample&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/SampleFileStore_2E00_cs"&gt;community.telligent.com/.../SampleFileStore_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once the plugin is installed and enabled, the &amp;quot;sample&amp;quot; file store can be used by this or other plugins to add, remove or serve files (see [[Centralized File Storage]] for examples of CFS usage).&lt;/p&gt;
&lt;p&gt;By default, the files of a file store are stored within the default file store configured in the communityserver.config file, however, the CFS configuration can be customized to explicitly identify where specify which file storage provider (file system, Amazon S3, etc) should be used for each file store. This configuration is out of scope for this topic, however.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Securing_a_File_Store" name="Securing_a_File_Store"&gt;&lt;/a&gt;Securing a File Store&lt;/h2&gt;
&lt;p&gt;File stores are always fully accessible to code, however, the Verint Community platform enables securing the accessibility of users to read files by URL using extension plugin types to ICentralizedFileStore: IGloballySecuredCentralizedFileStore and ISecuredCentralizedFileStore.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Globally_Secured_File_Stores" name="Globally_Secured_File_Stores"&gt;&lt;/a&gt;Globally Secured File Stores&lt;/h3&gt;
&lt;p&gt;Globally secured file stores are the simplest form of secured file storage --&amp;nbsp;either everyone has access to a file or no one has access to a file. The accessibility is always global (applying to all users).&lt;/p&gt;
&lt;p&gt;To implement a globally secured file store, implement the [[api-documentation:IGloballySecuredCentralizedFileStore Plugin Type|IGloballySecuredCentralizedFileStore]] interface on your existing &lt;code&gt;ICentralizedFileStore&lt;/code&gt; and define the accessibility logic within the &lt;code&gt;IsAccessible()&lt;/code&gt; method. For example, below is a complete example showing an implementation of &lt;code&gt;IGloballySecuredCentralizedFileStore&lt;/code&gt; that disables all access to files within the path &amp;quot;secured&amp;quot; in the &amp;quot;sample&amp;quot; file store:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/SampleGloballySecuredFileStore_2E00_cs"&gt;community.telligent.com/.../SampleGloballySecuredFileStore_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a id="User-specific_Secured_File_Stores" name="User-specific_Secured_File_Stores"&gt;&lt;/a&gt;User-specific Secured File Stores&lt;/h3&gt;
&lt;p&gt;Unlike globally-secured file stores, user-specific secured file stores can be secured differently depending on the user attempting to access a file by URL. To implement a user-specific secured file store, implement the [[api-documentation:ISecuredCentralizedFileStore Plugin Type|ISecuredFileStore]] interface&amp;nbsp;on the existing&amp;nbsp;&lt;code&gt;ICentralizedFileStore&lt;/code&gt; and define the&amp;nbsp;&lt;code&gt;UserHasAccess()&lt;/code&gt; method.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For&amp;nbsp;example, I&amp;#39;ve secured the original &amp;quot;sample&amp;quot; file store so that only registered users (non-anonymous users) can access any files within the file store:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/SampleSecuredFileStore_2E00_cs"&gt;community.telligent.com/.../SampleSecuredFileStore_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This sample uses the [[api-documentation:Users In-Process API Service|Users API]]&amp;nbsp;to retrieve user details for the &lt;code&gt;userId&lt;/code&gt; provided to the &lt;code&gt;UserHasAccess()&lt;/code&gt; method and to determine if the provided user is anonymous.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Generating_Files_Or_Redirecting_Within_a_File_Store" name="Generating_Files_Or_Redirecting_Within_a_File_Store"&gt;&lt;/a&gt;Generating Files Or Redirecting&amp;nbsp;Within a File Store&lt;/h2&gt;
&lt;p&gt;At times, it may be necessary to redirect files within a file store or generate files on first access. For example, if a file must be processed and the processing is intensive (for example, LESS files processing or image resizing), the result should be stored, but it may be worthwhile to wait until the file is requested to create the processed version of the file.&lt;/p&gt;
&lt;p&gt;To enable these scenarios, the Verint Community platform defines the [[api-documentation:IFindableCentralizedFileStore Plugin Type|IFindableCentralizedFileStore]] extension to ICentralizedFileStore. This extension provides a file store with the opportunity to be notified when a file being requested doesn&amp;#39;t exist and enable the file store to adjust the file request.&lt;/p&gt;
&lt;p&gt;When a file isn&amp;#39;t found, the &lt;code&gt;IFindableCentralizedFileStore&lt;/code&gt; is provided with the file store key, path, and file name requested as referenced parameters. If the &lt;code&gt;IFindableCentralizedFileStore&lt;/code&gt; can find (or generate the file), it can update these identifiers and return &lt;code&gt;true&lt;/code&gt; (to identify the file as found). &amp;nbsp;If the file cannot be found or generated, returning &lt;code&gt;false&lt;/code&gt; will serve the regular 404/not-found response.&amp;nbsp;The finding process is generally transparent to the user, but may require an HTTP redirect depending on the file storage provider configured to serve the file store.&lt;/p&gt;
&lt;p&gt;In the following sample, I&amp;#39;ve updated the original sample file store to also implement &lt;code&gt;IFindableCentralizedFileStore&lt;/code&gt; with &lt;code&gt;FindFile()&lt;/code&gt; defined to redirect any missing files to the &amp;quot;notfound.png&amp;quot; file in the root of the file store:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/SampleFindableFileStore_2E00_cs"&gt;community.telligent.com/.../SampleFindableFileStore_2E00_cs&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: files, ICentralizedFileStore&lt;/div&gt;
</description></item><item><title>Interacting With Files</title><link>https://community.telligent.com/community/11/w/developer-training/65118/interacting-with-files/revision/1</link><pubDate>Thu, 13 Jun 2019 19:28:54 GMT</pubDate><guid isPermaLink="false">fe260e91-80e1-4a86-92e5-5b9541087337</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65118/interacting-with-files#comments</comments><description>Revision 1 posted to Developer Training by Ben Tiedt on 06/13/2019 19:28:54&lt;br /&gt;
&lt;p&gt;The Telligent Community platform provides support for creating file stores within the [[Centralized File Storage|Centralized File Storage System]] to enable plugins to store, secure, serve, and generate files.&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2&gt;&lt;a id="Why_Would_I_Create_a_File_Store" name="Why_Would_I_Create_a_File_Store"&gt;&lt;/a&gt;Why Would I Create a File Store?&lt;/h2&gt;
&lt;p&gt;A file store is a unique set of paths and files located within the [[Centralized File Storage|Centralized File Storage System (CFS)]].&amp;nbsp;Each file store is a self-contained set of files that can be independently secured and located on the storage provider (operating system file system, Amazon S3, etc) of choice.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When implementing a [[Plugins|plugin]] that needs to store files, it is best to store those files in the [[Centralized File Storage|CFS]] within a file store that you maintain. It is not advised to reuse an existing file store.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Creating_a_File_Store" name="Creating_a_File_Store"&gt;&lt;/a&gt;Creating a File Store&lt;/h2&gt;
&lt;p&gt;Creating a new file store within the [[Centralized File Storage|CFS]] requires implementing the [[api-documentation:ICentralizedFileStore Plugin Type|ICentralizedFileStore]] [[Plugins|plugin]] type. &lt;code&gt;ICentralizedFileStore&lt;/code&gt; adds only a single member to [[api-documentation:IPlugin Plugin Type|IPlugin]], the programmatic name of the file store. The name must be unique and must meet the naming guidelines of the [[Centralized File Storage|CFS]].&lt;/p&gt;
&lt;p&gt;As a sample, the is the full implementation of a sample file store with the key &amp;quot;sample&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/SampleFileStore_2E00_cs"&gt;community.telligent.com/.../SampleFileStore_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once the plugin is installed and enabled, the &amp;quot;sample&amp;quot; file store can be used by this or other plugins to add, remove or serve files (see [[Centralized File Storage]] for examples of CFS usage).&lt;/p&gt;
&lt;p&gt;By default, the files of a file store are stored within the default file store configured in the communityserver.config file, however, the CFS configuration can be customized to explicitly identify where specify which file storage provider (file system, Amazon S3, etc) should be used for each file store. This configuration is out of scope for this topic, however.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Securing_a_File_Store" name="Securing_a_File_Store"&gt;&lt;/a&gt;Securing a File Store&lt;/h2&gt;
&lt;p&gt;File stores are always fully accessible to code, however, the Telligent Community platform enables securing the accessibility of users to read files by URL using extension plugin types to ICentralizedFileStore: IGloballySecuredCentralizedFileStore and ISecuredCentralizedFileStore.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Globally_Secured_File_Stores" name="Globally_Secured_File_Stores"&gt;&lt;/a&gt;Globally Secured File Stores&lt;/h3&gt;
&lt;p&gt;Globally secured file stores are the simplest form of secured file storage --&amp;nbsp;either everyone has access to a file or no one has access to a file. The accessibility is always global (applying to all users).&lt;/p&gt;
&lt;p&gt;To implement a globally secured file store, implement the [[api-documentation:IGloballySecuredCentralizedFileStore Plugin Type|IGloballySecuredCentralizedFileStore]] interface on your existing &lt;code&gt;ICentralizedFileStore&lt;/code&gt; and define the accessibility logic within the &lt;code&gt;IsAccessible()&lt;/code&gt; method. For example, below is a complete example showing an implementation of &lt;code&gt;IGloballySecuredCentralizedFileStore&lt;/code&gt; that disables all access to files within the path &amp;quot;secured&amp;quot; in the &amp;quot;sample&amp;quot; file store:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/SampleGloballySecuredFileStore_2E00_cs"&gt;community.telligent.com/.../SampleGloballySecuredFileStore_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a id="User-specific_Secured_File_Stores" name="User-specific_Secured_File_Stores"&gt;&lt;/a&gt;User-specific Secured File Stores&lt;/h3&gt;
&lt;p&gt;Unlike globally-secured file stores, user-specific secured file stores can be secured differently depending on the user attempting to access a file by URL. To implement a user-specific secured file store, implement the [[api-documentation:ISecuredCentralizedFileStore Plugin Type|ISecuredFileStore]] interface&amp;nbsp;on the existing&amp;nbsp;&lt;code&gt;ICentralizedFileStore&lt;/code&gt; and define the&amp;nbsp;&lt;code&gt;UserHasAccess()&lt;/code&gt; method.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For&amp;nbsp;example, I&amp;#39;ve secured the original &amp;quot;sample&amp;quot; file store so that only registered users (non-anonymous users) can access any files within the file store:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/SampleSecuredFileStore_2E00_cs"&gt;community.telligent.com/.../SampleSecuredFileStore_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This sample uses the [[api-documentation:Users In-Process API Service|Users API]]&amp;nbsp;to retrieve user details for the &lt;code&gt;userId&lt;/code&gt; provided to the &lt;code&gt;UserHasAccess()&lt;/code&gt; method and to determine if the provided user is anonymous.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Generating_Files_Or_Redirecting_Within_a_File_Store" name="Generating_Files_Or_Redirecting_Within_a_File_Store"&gt;&lt;/a&gt;Generating Files Or Redirecting&amp;nbsp;Within a File Store&lt;/h2&gt;
&lt;p&gt;At times, it may be necessary to redirect files within a file store or generate files on first access. For example, if a file must be processed and the processing is intensive (for example, LESS files processing or image resizing), the result should be stored, but it may be worthwhile to wait until the file is requested to create the processed version of the file.&lt;/p&gt;
&lt;p&gt;To enable these scenarios, the Telligent Community platform defines the [[api-documentation:IFindableCentralizedFileStore Plugin Type|IFindableCentralizedFileStore]] extension to ICentralizedFileStore. This extension provides a file store with the opportunity to be notified when a file being requested doesn&amp;#39;t exist and enable the file store to adjust the file request.&lt;/p&gt;
&lt;p&gt;When a file isn&amp;#39;t found, the &lt;code&gt;IFindableCentralizedFileStore&lt;/code&gt; is provided with the file store key, path, and file name requested as referenced parameters. If the &lt;code&gt;IFindableCentralizedFileStore&lt;/code&gt; can find (or generate the file), it can update these identifiers and return &lt;code&gt;true&lt;/code&gt; (to identify the file as found). &amp;nbsp;If the file cannot be found or generated, returning &lt;code&gt;false&lt;/code&gt; will serve the regular 404/not-found response.&amp;nbsp;The finding process is generally transparent to the user, but may require an HTTP redirect depending on the file storage provider configured to serve the file store.&lt;/p&gt;
&lt;p&gt;In the following sample, I&amp;#39;ve updated the original sample file store to also implement &lt;code&gt;IFindableCentralizedFileStore&lt;/code&gt; with &lt;code&gt;FindFile()&lt;/code&gt; defined to redirect any missing files to the &amp;quot;notfound.png&amp;quot; file in the root of the file store:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/SampleFindableFileStore_2E00_cs"&gt;community.telligent.com/.../SampleFindableFileStore_2E00_cs&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>