<?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>HASH File. how i can get??</title><link>https://www.aras.com/community/f/development/38090/hash-file-how-i-can-get</link><description>Hello, I am trying to get the HASH value of a file. The fact, is that I want, before a user uploads a file, to check that that file has not been previously uploaded. I have looked in ARAS and the system already saves that value in &amp;quot;checksum&amp;quot; itemtype</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: HASH File. how i can get??</title><link>https://www.aras.com/community/thread/9677?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 16:17:17 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:5cbcadeb-3715-4bab-9ea2-7678f295dc65</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;I definitely think some users use the checksum in some way. But so far I haven&amp;acute;t seen Innovator using it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Innovator was not designed to encourage users to &amp;quot;reuse&amp;quot; file. But to be fair, hardly any of the software tools&amp;nbsp;that I know&amp;nbsp;are designed this way. I assume this is some kind of standard that has a reason. But I don&amp;acute;t know. Innovator at least reuses files when a new revision is created. Confluence by Atlassian is much worse. It copies the files on each revision. This will lead to funny results&amp;nbsp;when user embed 8GB videos and then the software counts any minor edit as new revision.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I so far haven&amp;acute;t had much problems when reusing files in Innovator. We encourage our users to do it themselves. Only Visual Collaboration couldn&amp;acute;t link&amp;nbsp;reused files in the past. Not sure if it works today, but keep an eye on that if the feature is relevant.&lt;/p&gt;
&lt;p&gt;My Innovator 12 doesn&amp;acute;t have the&amp;nbsp;&lt;span&gt;xxhash-asm. But the &amp;quot;vendors&amp;quot; folder indicate, that it is an external library. Probably this one:&amp;nbsp;&lt;a id="" href="https://github.com/Cyan4973/xxHash"&gt;https://github.com/Cyan4973/xxHash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When Aras has replaced this one in the newer versions, I wouldn&amp;acute;t spent too much time to understand this one.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Here is a very old&amp;nbsp;onInsertRow test Method that I once made: It checks the files as soon as the user drags it to the file relationship. Note the first sentence!! The code is called multiple times when user insert multiple files. This will lead to notable performance problems. You can use it on a test server, but not in production. You can try if you can read the checksum instead of the filename.&lt;/p&gt;
&lt;p&gt;It&amp;acute;s outdated code written against Innovator 11. Perfectly for you, I assume. But I wouldn&amp;acute;t use &amp;quot;soapSend&amp;quot;, &amp;quot;var&amp;quot;, &amp;quot;top&amp;quot; or the &amp;quot;typeOf&amp;quot; lines anymore. It&amp;acute;s really old code and it was one of the first Innovator Methods I ever created:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Obsolete. Method is not good for performance

// Angela [...] / 23.10.2017
// Users should not upload the same files more than once (except, of course, if they really want and need it.)
// Especially compliance files or datasheets that are applicaple for multible Items should be reused and not reuploaded again.
// This method check if one or more files with the same file name are already available on the vault server.
// The result will be displayed in a small info box on the left bottom.
// This Method is used in relevant RelationshipTypes (Action: OnInsertRow) and not the ItemTypes itself!

// Possilbe notification variants:
// top.aras.AlertError(&amp;quot;Das File hei&amp;#223;t &amp;quot; + filename); // classical Error message
// aras.AlertSuccess(&amp;quot;Das File hei&amp;#223;t &amp;quot; + filename); // Info box at the bottom left
// alert(&amp;quot;Das File hei&amp;#223;t &amp;quot; + filename); // Error message in the browser

// Ideas for further development:
// Instead of info box show dialog window with following options: 1. Keep my new file; 2. Use file from server; 3. Abort
// Add file WhereUsed info to info message: The File 1234.pdf is also used in Part Multicomp xy.

var prt = typeof(parent.document.item) == &amp;quot;object&amp;quot; ? parent.document : parent.parent;
var tmpThisItem = typeof(parent.document.thisItem) == &amp;quot;object&amp;quot; ? parent.document.thisItem : parent.thisItem;
var relshipNd = prt.item.selectSingleNode(&amp;quot;Relationships/Item[@id=&amp;#39;&amp;quot; + relationshipID + &amp;quot;&amp;#39; and related_id/Item]&amp;quot;);
if (!relshipNd) return;
var relatedNd = relshipNd.selectSingleNode(&amp;quot;related_id/Item&amp;quot;);
var filename = top.aras.getItemProperty(relatedNd, &amp;quot;filename&amp;quot;, undefined); // get File name propery
// var fileid = top.aras.getItemProperty(relatedNd, &amp;quot;id&amp;quot;, undefined); // get File id propery
// var thisRel = tmpThisItem.getItemsByXPath(&amp;quot;//Item[@id=&amp;#39;&amp;quot; + relationshipID + &amp;quot;&amp;#39;]&amp;quot;).getItemByIndex(0);
// var relationshipName = thisRel.getType(); // get name of Relationship

 // Look for Files with the same name
var query =&amp;quot;&amp;lt;Item type=\&amp;quot;File\&amp;quot; select=\&amp;quot;filename\&amp;quot;&amp;gt;&amp;quot;
	+ &amp;quot;&amp;lt;filename&amp;gt;&amp;quot; + filename + &amp;quot;&amp;lt;/filename&amp;gt;&amp;quot; 
    + &amp;quot;&amp;lt;/Item&amp;gt;&amp;quot;;

var fileItem = aras.soapSend(&amp;quot;GetItem&amp;quot;, query);

if (fileItem.getFaultCode() !== 0) // no Files found
{ 
	aras.AlertSuccess(&amp;quot;Es ist noch kein File mit dem Namen &amp;quot; + filename + &amp;quot; auf dem Server vorhanden.&amp;quot; ); 
	return;
}

var fileNodes = fileItem.getResult().selectNodes(&amp;quot;Item&amp;quot;);
var filesCount = fileNodes.length;

if (filesCount == 1)
{
     aras.AlertSuccess(&amp;quot;Es ist akuell 1 File mit dem Namen &amp;quot; + filename + &amp;quot; auf dem Server vorhanden!&amp;quot; );
} else {
     aras.AlertSuccess(&amp;quot;Es sind aktuell &amp;quot; + filesCount + &amp;quot; Files mit dem Namen &amp;quot; + filename + &amp;quot; auf dem Server vorhanden!&amp;quot;); 
}
return;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Your approach with checking the files before save/update is better.&amp;nbsp;You can check the file relationships when clicking on save. I maybe have a codesample somewhere, but haven&amp;acute;t checked it yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HASH File. how i can get??</title><link>https://www.aras.com/community/thread/9676?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 13:49:27 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:7257c6c0-31cf-4cd2-81cc-8c77f2888241</guid><dc:creator>FernandoCG</dc:creator><description>&lt;p&gt;Hello Angela, thanks to write!!!.&lt;/p&gt;
[quote userid="4412" url="~/f/development/38090/hash-file-how-i-can-get/9675"]great use case! I tried something similar 7 years ago, but only tried to match names and inform the user that duplicates exists. But I never used the draft.[/quote]
&lt;p&gt;Perfect, if I get it to work I&amp;#39;ll leave you the code in case it helps the community.&lt;/p&gt;
[quote userid="4412" url="~/f/development/38090/hash-file-how-i-can-get/9675"]It´s true that Innovator doesn´t use the checksum in any way.&amp;nbsp;[/quote]
&lt;p&gt;It is strange, since in the itemtype &amp;quot;Document&amp;quot;, there is the checksum attribute, which is in &amp;quot;File&amp;quot; and as foreign in &amp;quot;Document File&amp;quot;. The most logical thing, and even more so if there are many users, is that it will control in some way so that duplicate files are not uploaded.&lt;/p&gt;
&lt;p&gt;Right now, in my version of ARAS, when you press the save button &amp;quot;save item&amp;quot;, icon of a 3 1/2 floppy disk, from my time, hahaha. ARAS calculates the checksum and saves it. But as I mentioned, he does it in the file &amp;quot;xxhash-asm.min.js&amp;quot;, in the line 2, but it is not tabulated and has 132,387 characters, why ARAS???.&lt;br /&gt;From what I have seen, it does this if a file is added and it is saved, if 2 files are added it does not calculate the checksum, I don&amp;#39;t know why!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We had thought that the verification would be done when the user clicks on saving the Item. Since you can add the file in two ways, adding using the button, or doing a drag and drop in the grid.&lt;br /&gt;Ideally, if it is through the add button it should not be a problem, since the dialog box appears, but if it is dragged, it should handle the event. ARAS already executes code, since it adds the name of the file.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="/community/resized-image/__size/640x480/__key/communityserver-discussions-components-files/3/pastedimage1695908291234v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;If not, then we&amp;#39;ll see if we put the check right after saving, to notify the user and edit the line. But ideally it would not be able to save or upload the file.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regarding the &amp;quot;limitation&amp;quot; of passing the file path, it is logical and after 2 days and reading a thousand sites I was imagining it. If it weren&amp;#39;t like that it would be a waste!!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Well, I&amp;#39;m going to see how I can take the file from the &amp;quot;Files&amp;quot; grid, if possible, and call getFileChecksum.&lt;/p&gt;
&lt;p&gt;Thank you very much Angela!!!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HASH File. how i can get??</title><link>https://www.aras.com/community/thread/9675?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 12:51:36 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:6fa1e7e0-f4bd-4fa7-ac16-4520b637652c</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;great use case! I tried something similar 7 years ago, but only tried to match names and inform the user that duplicates exists. But I never used the draft.&lt;/p&gt;
&lt;p&gt;It&amp;acute;s true that Innovator doesn&amp;acute;t use the checksum in any way.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Where do you trigger your aras.vault.select function? Do you currently only use the Method editor? Or did you overwrite the relationship file selector?&lt;/p&gt;
&lt;p&gt;When your function is just used in a JS Method, the &amp;quot;undefined&amp;quot; error makes sense. You use aras.vault to pick a file. &amp;quot;File&amp;quot; is your fileobject. You use it in the alert to get the checksum. So far everything fine.&lt;/p&gt;
&lt;p&gt;Then you write a path to a local file and use this one to get the checksum. This will not work, at least not in todays world (previous browsers from the 90s had some options...). JS itself cannot read local content automatically. That&amp;acute;s a security constraint. Just imagine every website in the world would have the potential power to read your&amp;nbsp;local desktop content. So JS can only work with files, actively provided by the user with a file picker.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There are more flexible upload file options available than the aras.vault selector. But it depends on your overall usecase. At which point of the upload process do you want to do the checksum check?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HASH File. how i can get??</title><link>https://www.aras.com/community/thread/9674?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 08:15:00 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:bcafae5c-9331-408c-bc46-9f8dbd0c8f49</guid><dc:creator>FernandoCG</dc:creator><description>&lt;p&gt;Ok, as I thought it was easier than what I was trying.&lt;/p&gt;
&lt;p&gt;With &amp;quot;getFileChecksum&amp;quot; we get the value from the HASH without any problem, but we have to pass the value through a &amp;quot;file object&amp;quot; and I don&amp;#39;t know how to pass the &lt;span&gt;filepath&amp;nbsp;&lt;/span&gt;through a variable, for example &amp;quot;filename&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;aras.vault.selectFile().then(function(file) {
	alert( aras.vault.getFileChecksum(file));
	
	
    var fileName = &amp;quot;C:\\Users\\fernando.coronil\\Downloads\\Prueba.TXT&amp;quot;;
	alert( aras.vault.getFileChecksum(fileName));
	
	});
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Line 1-2 works fine.&lt;/p&gt;
&lt;p&gt;Line 5-6 i get an error: &amp;quot;undefined&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I try too to load the file object in the itemType &amp;quot;Document&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="/community/resized-image/__size/640x480/__key/communityserver-discussions-components-files/3/pastedimage1695895067785v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But nothing. i dont know how i must to get this as an file object.&amp;nbsp;&lt;span class="emoticon" data-url="https://www.aras.com/community/cfs-file/__key/system/emoji/1f62d.svg" title="Sob"&gt;&amp;#x1f62d;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>