[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Base64 Decoding/Raw vs. Post



   Oh! Ok...I get it. You've already captured the value of PDFData and
   TmpValue, but you write the file when you get the HOSLog3 element. I
   assume that follows the PDFData element, right?
   And HTTPAPI converts tag and attribute names to EBCDIC when we
   use�http_url_post_xml, right?

   On Wed, Apr 22, 2015 at 12:57 PM, Scott Mildenberger
   <[1]SMildenberger@xxxxxxxxxxxxxxxxxx> wrote:

     No it is in an element called 'PDFData' - there is a when where I
     save the value there.� I wait until I receive the HOSLog3 element
     before I decode and write the pdf file to the IFS.� The loop inside
     HOSLog3 for the attributes is just collecting other info I need but
     is not related to getting and saving the PDF file.
     Scott
     -----Original Message-----
     From: [2]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
     [mailto:[3]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
     Michael Ryan
     Sent: Wednesday, April 22, 2015 10:48 AM
     To: HTTPAPI and FTPAPI Projects

   Subject: Re: Base64 Decoding/Raw vs. Post
   Thanks Scott! Just what I needed! I take it the PDF file is in an
   attribute and not an element, right?
   On Wed, Apr 22, 2015 at 12:40 PM, Scott Mildenberger <
   [4]SMildenberger@xxxxxxxxxxxxxxxxxx> wrote:
   > I use http_url_post_xml() to receive a pdf file that is Base64
   encoded.
   > Below is my incoming() procedure.� In the tag PDFData is the Base64
   > encoded data and I decode and write it out to an IFS file when I
   > receive the tag HOSLog3.� Let me know if you have questions on
   anything I am doing here.
   >
   >� � � P Incoming� � � � B
   >� � � D Incoming� � � � PI
   >� � � D� �LoadId� � � � � � � � � � � 10i 0
   >� � � D� �depth� � � � � � � � � � � �10I 0 value
   >� � � D� �name� � � � � � � � � � � 1024A� �varying
   const
   >� � � D� �path� � � � � � � � � � �24576A� �varying
   const
   >� � � D� �value� � � � � � � � � � 65535A� �varying
   const
   >� � � D� �attrs� � � � � � � � � � � � �*�   �dim(32767)
   >� � � D� � � � � � � � � � � � � � � � � �   �const options(*varsize)
   >
   >� � � d Program� � � � �c� � � � � � � � �   �'UTILS/XUSERMSG'
   >
   >� � � D attrname� � � � s� � � � � �1024A� �varying
   >� � � D attrval� � � � �s� � � � � 65535A� �varying
   >� � � d BigMsg� � � � � s� � � � � � 512
   >� � � D count� � � � � �s� � � � � � �10I 0
   >� � � d Filename� � � � s� � � � � � 100� � varying
   >� � � d Msg� � � � � � �s� � � � � � �50
   >� � � d retlen� � � � � s� � � � � � �10i 0
   >� � � d TimeString� � � s� � � � � � �26
   >� � � d User� � � � � � s� � � � � � �10
   >
   >� � � D atoi� � � � � � PR� � � � � � 10i 0
   extproc('atoi')
   >� � � D� �string� � � � � � � � � � � � *� �value
   options(*string)
   >
   >
   >� � � �/free
   >� � � � � //Msg = 'In:' + name;
   >� � � � � //dsply Msg 'SCOTT';
   >� � � � � //Msg = 'Value:' + value;
   >� � � � � //dsply Msg 'SCOTT';
   >� � � � � select;
   >� � � � � � when name = 'HOSLog3';
   >� � � � � � � count = 1;
   >� � � � � � � dow http_nextXmlAttr(attrs: count: attrname:
   attrval);
   >� � � � � � � � select;
   >� � � � � � � � � when (attrname = 'id');
   >� � � � � � � � � � //Msg = 'ID=' + attrval;
   >� � � � � � � � � � //dsply Msg 'SCOTT';
   >� � � � � � � � � � LastIndex = %int(%trim(attrval));
   >� � � � � � � � � when (attrname = 'date');
   >� � � � � � � � � � LogDate = %date(%trim(attrval) : *ISO);
   >� � � � � � � � endsl;
   >� � � � � � � enddo;
   >
   >� � � � � � � //� Base64 decode the pdf
   >� � � � � � � retlen = apr_base64_decode(PDFData : TmpValue);
   >
   >� � � � � � � //� Create directory for this truck if it
   doesn't exist.
   >� � � � � � � Filename = '/home/Driver Logs/' + Truck;
   >� � � � � � � if syscall('crtdir dir(''' + Filename + ''')' :
   > 'CPFA0A0') <> '';
   >� � � � � � � � //� Send error message
   >� � � � � � � � dsply ('Error creating log directory for ' +
   Truck) 'SCOTT';
   >� � � � � � � � return;
   >� � � � � � � endif;
   >
   >� � � � � � � //� Store PDFData to an ifs file.
   >� � � � � � � Filename += '/Log' + %char(LogDate : *ISO0) +
   '.pdf';
   >� � � � � � � unlink(Filename);
   >� � � � � � � fd = open(Filename :
   >� � � � � � � � � � � � O_WRONLY+O_CREAT+O_CODEPAGE:
   >� � � � � � � � � � � � S_IRUSR + S_IWUSR + S_IXUSR
   >� � � � � � � � � � � � + S_IRGRP + S_IXGRP
   >� � � � � � � � � � � � + S_IROTH + S_IXOTH : 819);
   >� � � � � � � if fd < 0;
   >� � � � � � � � EscErrno(errno);
   >� � � � � � � � dsply ('RANDRTVLOG Write PDF Error: ' +
   %char(errno))
   > 'SCOTT';
   >� � � � � � � endif;
   >
   >
   >� � � � � � � if write(fd: %addr(PDFData): retlen) < retlen;
   >� � � � � � � � err = errno;
   >� � � � � � � � callp close(fd);
   >� � � � � � � � EscErrno(err);
   >� � � � � � � endif;
   >
   >� � � � � � � callp close(fd);
   >
   >� � � � � � when name = 'Vehicle';
   >� � � � � � � Truck = %trim(value);
   >
   >� � � � � � when name = 'PDFData';
   >� � � � � � � PDFData = value;
   >� � � � � � � TmpValue = %subst(PDFData : 1 : %len(value));
   >
   >� � � � � � when name = 'TotalRecordCount';
   >� � � � � � � QueueDepth = %int(%trim(value));
   >
   >� � � � � endsl;
   >
   >� � � �/end-free
   >� � � P� � � � � � � � �E
   >
   >
   > Scott
   >
   > -----Original Message-----
   > From: [5]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:
   > [6]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Michael Ryan
   > Sent: Wednesday, April 22, 2015 10:08 AM
   > To: HTTPAPI and FTPAPI Projects
   > Subject: Base64 Decoding/Raw vs. Post
   >
   > Ok...I need to receive a Base64 document in an XML tag. I'm currently
   > using http_url_post_raw and converting to EBCDIC, but that's not
   going
   > to work, is it? Dumb question: if I use http_url_post_xml to get the
   > Base64 data, that will still be in binary, right? And then I can
   > decode it and write it to a file, right?
   >
   > Anyone have an example? Thanks!
   >
   ----------------------------------------------------------------------

     > - This is the FTPAPI mailing list.� To unsubscribe, please go to:

   > [7]http://www.scottklement.com/mailman/listinfo/ftpapi
   >
   ----------------------------------------------------------------------
   > -
   >
   -----------------------------------------------------------------------
   This is the FTPAPI mailing list.� To unsubscribe, please go to:
   [8]http://www.scottklement.com/mailman/listinfo/ftpapi
   -----------------------------------------------------------------------

References

   1. mailto:SMildenberger@xxxxxxxxxxxxxxxxxx
   2. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   3. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   4. mailto:SMildenberger@xxxxxxxxxxxxxxxxxx
   5. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   6. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   7. http://www.scottklement.com/mailman/listinfo/ftpapi
   8. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------