[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Save File Stream As .tif Image
Paul,
HTTPAPI internally uses a 64k field to pass the element data to your
endOfElement() callback procedure, which most likely is the reason for the
problem.
Maybe you can try to call http_XmlReturnPtr() to let HTTPAPI pass a pointer
to your callback instead of a field. With http_XmlReturnPtr(*ON) you get a
data structure of the following format instead of a field for 'value':
d value_t ds qualified
d ptr *
d len 10i 0
d EndElement PR
d userdata * value
d depth 10I 0 value
d name 1024A varying const
d path 24576A varying const
d value likeds(value_t) const
d Attrs * dim(32767)
d const options(*varsize)
See also Chris' response to "returning more than 8192 bytes" from 10 th
October 2014.
Thomas.
Am 03.06.2015 um 10:26 schrieb Paul Park:
> 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 = '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 = '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: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>> [mailto: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:
>>> 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
>> -----------------------------------------------------------------------
>> -----------------------------------------------------------------------
>> This is the FTPAPI mailing list. To unsubscribe, please go to:
>> 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:
> 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
-----------------------------------------------------------------------