NetTalk Central

Author Topic: Changing BLOB contents  (Read 4180 times)

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Changing BLOB contents
« on: November 07, 2014, 06:03:01 PM »
Bruce,

     I'm uploading PDF's to a BLOB.  The file name is stored in the field con:Consent_name.  In the Validate embed for this field I have the following code:

If p_web.GSV('Con:Exp_Script') = 1
    
    CL# = QuickPDF.CreateLibrary()
    
    UL# = QuickPDF.UnlockKey('secret')
      
        LS# = st1.LoadFile('.\ExpirationScript.txt')        
        
        p_web.SSV('tempfile', st.Random(16, st:upper)&'.PDF')
        FB# = st2.FromBlob(Con:Consent_File)
        
        SF# = st2.SaveFile(p_web.GSV('tempfile')        
    
    L# = QuickPDF.LoadFromFile(p_web.GSV('tempfile'), '')    
        
    Remove(p_web.GSV('tempfile'))
    
    O# = QuickPDF.PageJavaScriptAction('O', st1.GetValue())
    
    MD0# = QuickPDF.SetCustomInformation('ConsentID', p_web.GSV('Con:Consent_ID'))    
    MD1# = QuickPDF.SetCustomInformation('IRBNumber', p_web.GSV('Con:IRBNumber'))    
    MD2# = QuickPDF.SetCustomInformation('AppDate', p_web.GSV('Con:Consent_Approval_Date'))    
    MD3# = QuickPDF.SetCustomInformation('ExpDate', p_web.GSV('Con:Consent_Expiration_Date'))  

    p_web.SSV('tempfile', st3.Random(16, st:upper)&'.PDF')
  
    S# = QuickPDF.SaveToFile(p_web.GSV('tempfile'))
        
    LF# = st3.LoadFile(p_web.GSV('tempfile'))
    B# = st3.ToBLOB(Con:Consent_File)
    
    Remove(p_web.GSV('tempfile'))
END


This all works well with an Insert.  Now, if I click change, to add a description or change a date, then save, the contents of my BLOB are altered.  This also happens when I click change, but do nothing and click save to back out.  I want the BLOB to change only if I upload another file during the change process.  I have tried the Post Insert/Change and save file embeds as well, but can't figure this out.

Is there another embed or method I should look at?  I need to control whether the BLOB is changed or not, based on if a new file is uploaded.

Thanks,

Jeff
« Last Edit: November 07, 2014, 06:05:41 PM by kingja »

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Solved - Re: Changing BLOB contents
« Reply #1 on: November 10, 2014, 06:51:06 AM »
My original plan was to modify the PDF's just after they were uploaded.  I could not find the right combination of code and embeds, I think it is a "timing" issue.  So I decided to add all my code to the ServeDocument procedure.  Now, I modify the PDF's just before sending them back to the user.  So far, works pretty well.

Thanks,

Jeff