[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Save File Stream As .tif Image
Hi Paul,
have you tried to pass to�base64_decode function only the DATA?
Replace�%addr(sb2_data) by�%addr(sb2_data: *DATA)
In this case you call should look like this:
base64_decode( %addr(sb2_data: *DATA)
: %len(sb2_data)
: %addr(outVar)
: %size(outVar));
Good luck,
Radu�
On Wed, Jun 3, 2015 at 10:26 AM, Paul Park <[1]parkp@xxxxxxxxxx> wrote:
Hi
Thanks very much for the replies!
Thomas: it's base 64 binary data contained within an XML element
called File_Stream. In the procedure that gets called at "end of XML
element", I have this:
� � �P endOfElement� � b
� � �D endOfElement� � pi
� � �D� userData� � � � � � � � � � � �*� �value
� � �D� depth� � � � � � � � � � � � 10i 0 value
� � �D� name� � � � � � � � � � � �1024a� �varying
const
� � �D� path� � � � � � � � � � � 24576a� �varying
const
� � �D� value� � � � � � � � � � � � � � � like(streamBlob) const
� � �D� attrs� � � � � � � � � � � � � *� �dim(32767)
� � �D� � � � � � � � � � � � � � � � � � �const options(*varsize)
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �D rc1� � � � � � �S� � � � � � �10I 0
� � �D sb2� � � � � � �s� � � � � � � � � �SQLTYPE(BLOB:9999999)
� � �D outVar� � � � � s� � � � � 32767a� �varying
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � /free
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �select;
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �// File stream
� � � � �when name = 'File_Stream';
� � � � � �fd = open(
� � � � � � �'/ppk/image.tif':
� � � � � � �O_CREAT+O_WRONLY:
� � � � � � �S_IWUSR+S_IRUSR+S_IRGRP+S_IROTH);
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �sb2 = value;
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �// Convert to base 64
� � � � � �base64_decode( %addr(sb2_data)
� � � � � � � � � � : %len(sb2_data)
� � � � � � � � � � : %addr(outVar)
� � � � � � � � � � : %size(outVar));
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �rc1 = write(fd: %addr(outVar): %size(outVar));
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �endsl;
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � /end-free
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �P endOfElement� � e
However, when the base64_decode procedure is called, it fails with
"Unable to decode character at position 65534. (Char=x'40')". When I
debug the program and look at the contents of sb2_data, position
65534 is indeed blank. Positions 1 - 65533 do have data though. How
can I fix this problem?
Mike: thanks for those code samples. I'll have a go at running them.
I don't think I have a problem viewing tifs (it's hard to know at
this point!) but those samples are useful for me to get a better
idea of what else I can do with HTTPAPI.
Paul
On 02/06/2015 22:30, Mike Krebs wrote:
How is your ability to download and view any other .tif?
If you want to try, here is a short program to download a .tif to
/tmp/ccitt_1.tif
H DFTACTGRP(*NO) BNDDIR('HTTPAPI')
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � /copy qrpglesrc,httpapi_h
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � D rc� � � � � � � s� � � � � � �10I 0
D msg� � � � � � �s� � � � � � �52A
D URL� � � � � � �S� � � � � � 300A� � varying
D IFS� � � � � � �S� � � � � � 256A� � varying
D errNo� � � � � �S� � � � � � �10i 0
D retries� � � � �S� � � � � � �10i 0
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �callp� � �http_debug(*ON)
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �eval� � � URL = '[2]http://www.fileformat.info'
c� � � � � � � � � � � � � � � � �+
'/format/tiff/sample/'
c� � � � � � � � � � � � � � � � �+
'3794038f08df403bb446a97f897c578d/'
c� � � � � � � � � � � � � � � � �+ 'download'
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �eval� � � IFS = '/tmp/ccitt_1.tif'
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �eval� � � rc = http_url_get(URL: IFS : 5)
� �if rc = 302;
� � �rc = http_url_get(http_redir_loc: ifs);
� /copy qrpglesrc,httpapi_h
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � D rc� � � � � � � s� � � � � � �10I 0
D msg� � � � � � �s� � � � � � �52A
D URL� � � � � � �S� � � � � � 300A� � varying
D IFS� � � � � � �S� � � � � � 256A� � varying
D errNo� � � � � �S� � � � � � �10i 0
D retries� � � � �S� � � � � � �10i 0
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �callp� � �http_debug(*ON)
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �eval� � � URL = '[3]http://www.fileformat.info'
c� � � � � � � � � � � � � � � � �+
'/format/tiff/sample/'
c� � � � � � � � � � � � � � � � �+
'3794038f08df403bb446a97f897c578d/'
c� � � � � � � � � � � � � � � � �+ 'download'
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �eval� � � IFS = '/tmp/ccitt_1.tif'
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �eval� � � rc = http_url_get(URL: IFS : 5)
� �if rc = 302;
� � �rc = http_url_get(http_redir_loc: ifs);
� �endif;
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �if� � � � rc <> 1
c� � � � � � � � � �eval� � � retries = 0
c� � � � � � � � � �eval� � � msg = http_error(errNo)
c� � � � � � � � � �dow� � � �errNo = 7 and retries <
5
c� � � � � � � � � �callp� � �http_dmsg('rc= ' +
%char(rc))
c� � � � � � � � � �callp� � �http_dmsg('retries= ' +
%char(retries))
c� � � � � � � � � �eval� � � rc = http_url_get(URL:
IFS : 5)
c� � � � � � � � � �if� � � � rc = 1
c� � � � � � � � � �eval� � � retries = *hival
c� � � � � � � � � �else
c� � � � � � � � � �eval� � � msg = http_error(errNo)
c� � � � � � � � � �eval� � � retries += 1
c� � � � � � � � � �endif
c� � � � � � � � � �enddo
c� � � � � � � � � �endif
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � c� � � � � � � � � �eval� � � *inlr = *on
-----Original Message-----
From: [4]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:[5]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
Thomas Raddatz
Sent: Tuesday, June 2, 2015 12:42 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: Save File Stream As .tif Image
Paul,
What kind of stream do you get back. Is the the binary image stream
or is it an XML message with the image data as part of an xml
element?
I assume that you get back an XML message. So how is the binary
image data encoded? Base64? Something else?
Can you provide a sample response message? You may shorten the image
data if it is to big. Just include, let's say, the first 30 and last
30 bytes of the image data.
Thomas.
Am 02.06.2015 um 13:31 schrieb Paul Park:
Hi
The HTTPAPI service programs are working a treat for us, but I have
run into a problem.
I am using http_url_post_xml to post an XML request containing an
ID.
The response I get back contains the "file stream" for a .tif image.
I
want to save this data in a .tif file, in the IFS, so that when I
open
it I can see the image. The image is destined for display on a web
page. So far, I can save the file stream in example.tif but it
doesn't open as an image.
I don't think this is specifically a HTTPAPI problem, but does
anyone
know what I need to do to save the file stream properly as a .tif
image?
Thanks for any assistance.
Cheers,
Paul
Enterprise Software Systems.
Company No 3374336. Registered in England, Registered Office:
Enterprise House, Pacific Road Altrincham, Cheshire, WA14 5EN
The information in this email is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this
email by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution or any action taken
or omitted to be taken in reliance on it, is prohibited and may be
unlawful. If you are not the intended addressee please contact the
sender and dispose of this e-mail.
--------------------------------------------------------------------
--
- This is the FTPAPI mailing list.� To unsubscribe, please go to:
[6]http://www.scottklement.com/mailman/listinfo/ftpapi
--------------------------------------------------------------------
--
-
--------------------------------------------------------------------
---
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
--------------------------------------------------------------------
---
Enterprise Software Systems.
Company No 3374336. Registered in England,
Registered Office: Enterprise House, Pacific Road
Altrincham, Cheshire, WA14 5EN
The information in this email is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this
email
by anyone else is unauthorized. If you are not the intended
recipient, any
disclosure, copying, distribution or any action taken or omitted to
be
taken in reliance on it, is prohibited and may be unlawful. If you
are not
the intended addressee please contact the sender and dispose of this
e-mail.
--------------------------------------------------------------------
---
This is the FTPAPI mailing list.� To unsubscribe, please go to:
[9]http://www.scottklement.com/mailman/listinfo/ftpapi
--------------------------------------------------------------------
---
--
R.
References
1. mailto:parkp@xxxxxxxxxx
2. http://www.fileformat.info/
3. http://www.fileformat.info/
4. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
5. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
6. http://www.scottklement.com/mailman/listinfo/ftpapi
7. http://www.scottklement.com/mailman/listinfo/ftpapi
8. http://www.scottklement.com/mailman/listinfo/ftpapi
9. 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
-----------------------------------------------------------------------