• Anonymous user can't upload files with authorization code + SOLUTION

    By Janko Stefancic 1 decade ago

    I create and send an authorization code to a user, which accesss fileSendr with Anonymous access.
    When he tries to upload the files this error is thrown:

    Exception occurred calling method NotesDocument.save(boolean) null

     

    Solution (FIX):

    1) Custom control: cc_fileUploader
    a) Computed field: cf_EmbedUploadedFilesToDoc = change the code to use sessionAsSigner to access and save document

    2) Custom control: browser_uploadFiles
    a) Button: button1 (Upload and save files) = same thing change the code to use sessionAsSigner

     

    Example: browser_uploadFiles

    // Get the current document and it&#39;s changes</div>
    
    <strong>var dbC:NotesDatabase = sessionAsSigner.getDatabase(database.getServer(), database.getFilePath());</strong></div>
    
    <strong>var thisDoc:NotesDocument = dbC.getDocumentByUNID( authDoc.getDocument(true).getUniversalID() );&nbsp;</strong></div>
    
    &nbsp;</div>
    
    // Set the authorization key to used</div>
    
    <strong>thisDoc.replaceItemValue(&quot;$PublicAccess&quot;,&quot;1&quot;);</strong></div>
    
    thisDoc.replaceItemValue(&quot;IsUsed&quot;,&quot;true&quot;);</div>
    
    thisDoc.replaceItemValue(&quot;file_Storage&quot;,&quot;local&quot;)</div>
    
    thisDoc.save();</div>
    

     

    I can send you both custom controls with the fixed code if you want.

     

     

    <strong>// Get the current document and it&#39;s changes</strong></div>
    
    <strong>var dbC:NotesDatabase = sessionAsSigner.getDatabase(database.getServer(), database.getFilePath());</strong></div>
    
    <strong>var thisDoc:NotesDocument = dbC.getDocumentByUNID( authDoc.getDocument(true).getUniversalID() );&nbsp;</strong></div>
    
    &nbsp;
    
    <strong>// Set the authorization key to used</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;$PublicAccess&quot;,&quot;1&quot;);</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;IsUsed&quot;,&quot;true&quot;);</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;file_Storage&quot;,&quot;local&quot;)</strong></div>
    
    <strong>thisDoc.save();</strong></div>
    


     

     

    <strong>// Get the current document and it&#39;s changes</strong></div>
    
    <strong>var dbC:NotesDatabase = sessionAsSigner.getDatabase(database.getServer(), database.getFilePath());</strong></div>
    
    <strong>var thisDoc:NotesDocument = dbC.getDocumentByUNID( authDoc.getDocument(true).getUniversalID() );&nbsp;</strong></div>
    
    &nbsp;
    
    <strong>// Set the authorization key to used</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;$PublicAccess&quot;,&quot;1&quot;);</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;IsUsed&quot;,&quot;true&quot;);</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;file_Storage&quot;,&quot;local&quot;)</strong></div>
    
    <strong>thisDoc.save();</strong></div>
    
    <strong>// Get the current document and it&#39;s changes</strong></div>
    
    <strong>var dbC:NotesDatabase = sessionAsSigner.getDatabase(database.getServer(), database.getFilePath());</strong></div>
    
    <strong>var thisDoc:NotesDocument = dbC.getDocumentByUNID( authDoc.getDocument(true).getUniversalID() );&nbsp;</strong></div>
    
    &nbsp;
    
    <strong>// Set the authorization key to used</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;$PublicAccess&quot;,&quot;1&quot;);</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;IsUsed&quot;,&quot;true&quot;);</strong></div>
    
    <strong>thisDoc.replaceItemValue(&quot;file_Storage&quot;,&quot;local&quot;)</strong></div>
    
    <strong>thisDoc.save();</strong></div>
    
    • Correct code... (can't edit my document)

      By Janko Stefancic 1 decade ago

      It seems that you have to handle only ANONYMOUS users... my previous fix broke the normal send files from logged users.

      if (context.getUser().getCommonName().toUpperCase() == "ANONYMOUS") {
         var dbC:NotesDatabase = sessionAsSigner.getDatabase(database.getServer(), database.getFilePath());
         var thisDoc:NotesDocument = dbC.getDocumentByUNID( authDoc.getDocument().getUniversalID() );
      } else {
         var thisDoc:NotesDocument = authDoc.getDocument(true);

      • Can you send me the code

        By Anthony J Miller 1 decade ago

        Can you send me your fixes?