<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.aras.com/community/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/f/development/6621/how-to-add-restrictions-to-aras-vault-selectfile-file-picker</link><description>Hi community, 
 I currently design a custom form with a button that calls a regular file picker. In my scenario, end users shall only be able to upload certain datatypes, like txt and xml. As the affected users group does not have any edit rights for</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/9088?ContentTypeID=1</link><pubDate>Tue, 20 Dec 2022 17:19:13 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:d9c4fa0b-0e46-4df8-8050-5088611f8a02</guid><dc:creator>Gopikrishnan</dc:creator><description>&lt;p&gt;I&amp;#39;m able to upload the file using below code snippet&lt;pre class="ui-code" data-mode="javascript"&gt;function addFilesToVault(fileItem)
{
    const uploadedFile = aras.newItem(&amp;quot;File&amp;quot;, fileItem);
    if (uploadedFile)
    {
        aras.itemsCache.addItem(uploadedFile);
        window.aras.saveItemExAsync(uploadedFile).then(unlockFileItem.bind(this));
    }
}
function unlockFileItem(fileItem)
{
    window.aras.unlockItemAsync(aras.getItemProperty(fileItem, &amp;quot;id&amp;quot;), &amp;quot;File&amp;quot;);
}
aras.vault.selectFile().then(addFilesToVault.bind(this));&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/9083?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2022 09:54:49 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:7f86f5c5-7e7c-41a5-a140-19f93ee852ee</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Are there new developer or programmers guide that cover this?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In my case I often use a custom html file picker, but the same file upload code as shown above. If you are able to find a solution, would be happy to know!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/9082?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2022 09:37:11 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:191500d4-62f3-4d5c-ac38-dcab7520ce0c</guid><dc:creator>Gopikrishnan</dc:creator><description>&lt;p&gt;Only the upload fails with a error message &amp;quot;&lt;span&gt;File Item cannot be added.&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/9081?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2022 09:35:44 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:c2a4e8a0-bff8-4e25-8793-b9fe01454682</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Do you still get the file picker dialog? Or does only the file upload fail?&lt;/p&gt;
&lt;p&gt;In my 12SP7 selectFile() function was moved to ArasModules --&amp;gt; ArasModules.vault.selectFile()....&lt;/p&gt;
&lt;p&gt;Cannot tell for Innovator 15, cause I still wait for the next open release....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/9074?ContentTypeID=1</link><pubDate>Sat, 17 Dec 2022 14:36:48 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:9dfd21d3-077b-4792-b709-acfc9193aa10</guid><dc:creator>Gopikrishnan</dc:creator><description>&lt;p&gt;I was trying to upload a file using the code snippet shared by Chris but it is not working in ARAS15 version. I&amp;rsquo;m getting file items cannot be added error.&amp;nbsp;&lt;a href="/community/members/angela"&gt;AngelaIp&lt;/a&gt; Did you have any solution for this error?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/4349?ContentTypeID=1</link><pubDate>Mon, 10 Feb 2020 16:03:21 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:09887c8e-d556-4523-9ea5-fdcc0701952e</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Hi Chris,&lt;/p&gt;
&lt;p&gt;thanks for this solution! The obsolete version still works fine, but I prefer to use the more future-proof version. I replaced my current code with your new version. Worked!&lt;/p&gt;
&lt;p&gt;I agree that a regular upload within a context item is probably the better approach. But I am not sure if this is possible in my current use case.&lt;/p&gt;
&lt;p&gt;In my current use case an external (!) user shall be able to upload a file into an existing item. The user must not be able to edit any of the other fields.&amp;nbsp;&lt;span&gt;So the external user&amp;nbsp;only has &amp;quot;Get&amp;quot; permission for the item.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I was thinking about different concepts of how to achieve this one:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. Property based permissions (as seen in the corresponding community project).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp;Give user full edit permissions, but use a custom Form so user cannot edit field in Form. This one would be a simple solution, but user could still edit all fields via AML or Rest API.&lt;/p&gt;
&lt;p&gt;3. Edit via Server Method that grants permission for editing only the specific item property. This is the variant I currently use. But as this one runs on the server, I have to separate File upload and the actual edit of the context item.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am not sure if there are other variants available. The &amp;quot;Grant permission&amp;quot; variant right now seems to be the best mix of security and usability.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/4331?ContentTypeID=1</link><pubDate>Thu, 06 Feb 2020 19:19:17 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:19f300d6-98af-40c3-a4c2-7239dc3769fe</guid><dc:creator>Christopher Gillis</dc:creator><description>&lt;p&gt;Hi Angela,&lt;/p&gt;
&lt;p&gt;It looks like this is&amp;nbsp;&lt;em&gt;setFileName&lt;/em&gt; was an older function intended to work when adding File items as you&amp;#39;re doing. It&amp;#39;s listed as obsolete in the IOM API though, so I&amp;#39;d recommend updating the code in the event that support for it is removed in the future.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://www.aras.com/-/media/files/documentation/other-documentation/en/12-0/aras-innovator-120--programmers-guide.ashx"&gt;Programmer&amp;#39;s Guide&lt;/a&gt; recommends using the&amp;nbsp;&lt;em&gt;setFileProperty&lt;/em&gt; function when adding files using&amp;nbsp;&lt;em&gt;vlt.selectFile()&lt;/em&gt;. However, this seems to be intended for when you are adding files in the context of another item (the&amp;nbsp;&lt;em&gt;native_file&lt;/em&gt; property of CAD in the example in the programmer&amp;#39;s guide) and not when you&amp;#39;re adding File items directly. I tried testing&amp;nbsp;&lt;em&gt;fileItem.setFileProperty(&amp;quot;id&amp;quot;, fileObject);&lt;/em&gt; in my local environment but that didn&amp;#39;t&amp;nbsp;work for me. If you don&amp;#39;t need to add the file directly, I&amp;#39;d recommend this approach.&lt;/p&gt;
&lt;p&gt;If you do need to add File items outside of the context of another item like you&amp;#39;re currently doing, you could try this approach using &lt;em&gt;aras.newFileItem&lt;/em&gt;:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;vlt.selectFile().then(function(fileObj)&lt;/em&gt;&lt;br /&gt;&lt;em&gt;{&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; var newFile = aras.newFileItem(fileObj);&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; var fileId = newFile.getAttribute(&amp;quot;id&amp;quot;);&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; var fileItem = aras.IomInnovator.newItem();&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; fileItem.loadAML(newFile.xml);&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; fileItem.apply();&lt;/em&gt;&lt;br /&gt;&lt;em&gt;});&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This code worked for me in a 12.0 SP4 instance. Note that the functions defined on the&amp;nbsp;&lt;em&gt;aras&lt;/em&gt; object are typically more subject to change the functions in the IOM like&amp;nbsp;&lt;em&gt;setFileProperty&lt;/em&gt;. If you don&amp;#39;t need to add Files directly, the recommended approach would be the one in the Programmer&amp;#39;s Guide.&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Christopher Gillis&lt;/p&gt;
&lt;p&gt;Aras Labs Software Engineer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/4330?ContentTypeID=1</link><pubDate>Thu, 06 Feb 2020 12:42:35 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:80de0982-9fae-4bd1-9385-bd10e70ba55a</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Hi Chris,&lt;/p&gt;
&lt;p&gt;I would have a short question regarding this thread. In my sample code I use the following code for file upload:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;var fileItem = inn.newItem(&amp;quot;File&amp;quot;,&amp;quot;add&amp;quot;);&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;fileItem.setFileName(fileObject);&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;fileItem = fileItem.apply();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The code works, but I wonder if this is the recommended way to upload a file from client side. I am little bit confused&amp;nbsp;about&amp;nbsp;&lt;strong&gt;setFileName(fileObject).&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The fileObject contains much more than the name of the file. Do you have a better sample for the file upload? I have no idea where I got this code, I assume I have&amp;nbsp;programmed it by accident. So it maybe just works in my current Innovator version.&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/4051?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2019 10:12:11 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:68d27455-c3a1-4124-a9b5-e29d3cc049c8</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Hi Chris,&lt;/p&gt;
&lt;p&gt;thanks for the hint to use a custom file picker. There is no big difference between the Aras file picker and the native javascript one, so I were able to reuse my existing code without having to change everything. I can confirm the the accept attribute turned out to be just a visual help. But I still prefer the custom variant, as I can also use it to display the picked files more easily.&lt;/p&gt;
&lt;p&gt;It&amp;acute;s even possible to add drag&amp;amp;drop option to the file picker. I like this option, as it can reused for other scenarios in Innovator, like the upload of Tech Doc graphics. Main challenge is somehow when you want to use css, cause there are some browser specific limitations to consider. Never start designing in Chrome, when the target audience is using IE mostly :-).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add restrictions to aras.vault.selectFile() file picker</title><link>https://www.aras.com/community/thread/4023?ContentTypeID=1</link><pubDate>Tue, 26 Nov 2019 18:50:40 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:bf369fa0-a14d-47ad-a709-1403a9cc33c6</guid><dc:creator>Christopher Gillis</dc:creator><description>&lt;p&gt;Hi Angela,&lt;/p&gt;
&lt;p&gt;The file picker is basically just using a standard HTML input element with the&amp;nbsp;&lt;em&gt;file&lt;/em&gt; type. This file input type supports an additional attribute called&amp;nbsp;&lt;em&gt;accept&lt;/em&gt; which you can use to pass in a comma separated list of extensions and mime types that you want your users to be able to pick from. There&amp;#39;s a good explanation of it with some nice examples on &lt;a href="https://stackoverflow.com/a/23706177"&gt;this StackOverflow answer&lt;/a&gt;. In your case, you&amp;#39;d want to set an attribute like&amp;nbsp;&lt;em&gt;accept=&amp;quot;.txt, .xml&amp;quot;&lt;/em&gt; . Note that in most browsers this will typically apply a default filter, but users will still be able to opt out of the filter to select any file they want. Because of this, your checks on the file once it&amp;#39;s returned should still be included.&lt;/p&gt;
&lt;p&gt;For your use case, I&amp;#39;d recommend using a custom&amp;nbsp;&lt;em&gt;&lt;/em&gt;file input element rather than the one used by the&amp;nbsp;&lt;em&gt;selectFile()&lt;/em&gt; function which exists in the codetree. This will make it easier to modify in the future as well as allow for the possibility of accepting different file types for different users or situations.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Chris&lt;/p&gt;
&lt;p&gt;Christopher Gillis&lt;/p&gt;
&lt;p&gt;Aras Labs Software Engineer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>