How to apply code for decode base64 Zip File and extract the XML File in NAV2009 Classic Client?.

kovaidon
kovaidon Member Posts: 55
Hi,

how to apply code to decode Base64 Zip File in Blob Field and extract the File from Zip Folder in NAV2009Classic Client. Now with existing code it works fine when attachment in XML file is PDF, it is properly encoded and write the file details in Blob field and read (decode) in Navision. But when it is Zip File, it throws error while decoding like below.
qturrjq23581.png



Answers

  • TallyHo
    TallyHo Member Posts: 417
    edited 2019-03-05
    unzipping:
    https://dynamics.is/?p=275

    Base64 decoding:
    Automation = 'CG Request Client'.Base64
    obtain it installing commerce gateway from nav installation

    IF ISCLEAR(XMLNode) THEN
    ERROR(Text001);
    IF ISCLEAR(Base64) THEN
    CREATE(Base64);
    Bestand.CREATETEMPFILE;
    FileName := Bestand.NAME;
    Bestand.CLOSE;
    Base64.Decode(FileName,XMLNode);
    CLEAR(TempBlob);
    TempBlob.Blob.CREATEOUTSTREAM(Outs);
    Bestand.OPEN(FileName);
    Bestand.CREATEINSTREAM(Ins);
    COPYSTREAM(Outs,Ins);
    Bestand.CLOSE;
    ERASE(FileName);


  • kovaidon
    kovaidon Member Posts: 55
    edited 2019-03-05
    Hi TallyHo,

    Thanks for your kind suggestion. But that does not works as expected,again same error. is popping up.
  • TallyHo
    TallyHo Member Posts: 417
    Hm.. try not to save it as a .zip file after extraction from base64.
    So save it without extension, and unzip it with the unzip code in my link