O$5.1.1 Loading image file to a variable using HTTPRead.
Thanks Doug.
Kelly showed me the way to find the start of the file, so now I have the binary and have saved the file. And it works, so HTTPPage is the best function to use.
The oBrowser was interesting to use, and when I passed in the URL, it showed up quickly. But unnecessary of course.
See you at EurOmnis 2017, coming up very soon.
Mike
Mike Matthews, Managing Director, Lineal Software Solutions Ltd
Apple Reseller, Microsoft Partner, SQLWorks Business Partner
phone: 01271 375999 | web: lineal.co.uk <www.lineal.co.uk/> | email: mike.matthews@lineal.co.uk <mailto:mike.matthews@lineal.co.uk>
> On 4 Jul 2017, at 14:59, Doug Easterbrook <doug@artsman.com> wrote:
>
> hi mike.
>
> if y are using something like httpPage to grab a web page, there is no easier way to get what you want other than to parse the web page and look for the items in it you want — as well as dealing with thinks liker 404 (page not found) and 503 (page redirects) etc.
>
> thats just the way of things when parsing a URL
>
>
> if the site offers a REST API — then you can grab things in a programatic way and in a format you like (like JSON or XML) …
>
>
>
> oBrowser is not a way to get web pages — its a way to display them in omnis.
>
>
>
> Doug Easterbrook
> Arts Management Systems Ltd.
> mailto:doug@artsman.com
> www.artsman.com
> Phone (403) 650-1978
>
>> On Jul 3, 2017, at 2:02 PM, Mike Matthews <omnis@lineal.co.uk> wrote:
>>
>> Has anyone an easier, more workable solution to retrieving an image from a website please?
>>
>> I have the URL of the image as:
>> www.plastimo.com/media/catalog/product/e/c/eclate_pieces_detachees_enrouleur_1.jpg <www.plastimo.com/media/catalog/product/e/c/eclate_pieces_detachees_enrouleur_1.jpg>
>>
>> and I want to be able to save the image on my local PC. I get so far, I can connect, get back both binary data and the full HTML text. But I was hoping with v8, there would be an easier way now. Would this oBrowser object be a saviour perhaps?
>>
>> Thank you
>>
>> Mike
>>
>>
>>
>> Mike Matthews, Managing Director, Lineal Software Solutions Ltd
>>
>> Apple Reseller, Microsoft Partner, SQLWorks Business Partner
>> phone: 01271 375999 | web: lineal.co.uk <www.lineal.co.uk/> | email: mike.matthews@lineal.co.uk <mailto:mike.matthews@lineal.co.uk>
>>> On 24 Oct 2011, at 00:33, George Panagopoulos <eyeway1@otenet.gr> wrote:
>>>
>>> Hi Mark,
>>>
>>> Unfortunately it didn’t work for me, but I found a workaround wich is working( at least it looks like it does!)
>>>
>>> Here is the code I used to make it work.
>>>
>>> HTTPSplitURL (ivPictureLink,lvHost,lvURI)
>>> HTTPGet (lvHost,lvURI) Returns lvSocket
>>> HTTPRead (lvSocket,ivBuffer,2) Returns lvByteCount
>>> HTTPPage (ivPictureLink) Returns ivHTMLText
>>> HTTPClose (lvSocket)
>>> Calculate lvPosition as pos(‘Content-Length:’,ivHTMLText)
>>> Calculate lvSize as mid(ivHTMLText,lvPosition+15,7)
>>> Calculate lvOffset as lvByteCount-lvSize
>>> Calculate ivPicture as bytemid(ivBuffer,lvOffset,lvByteCount)
>>> Calculate ivPictureConv as pictconvfrom(‘cs24’,ivPicture)
>>>
>>> Thank you for your help. Your suggestion gave me the idea for the code above.
>>>
>>> Regards,
>>>
>>> George
>>>
>>> On 20/10/2011 22:22, Mark Watson wrote:
>>>> Hi George,
>>>>
>>>> I’ve found that the http stuff from a picture download ends with
>>>> chr(13),chr(10),chr(13),chr(10) – at least for jpg and png files, so try
>>>> forming another binary variable containing everything after that character
>>>> sewuence. For example, if lvBuffer is your downloaded binary, :
>>>>
>>>> Calculate lvBuffer2 as bytemid(
>>>> lvBuffer,binsearch(con(chr(13),chr(10),chr(13),chr(10)),lvBuffer)+4,binlengt
>>>> h(lvBuffer)-1)
>>>>
>>>> Mark Watson
>>>>
>>>>
>>>> —–Message d’origine—–
>>>> De : omnisdev-en-bounces@lists.omnis-dev.com
>>>> [mailto:omnisdev-en-bounces@lists.omnis-dev.com] De la part de George
>>>> Panagopoulos
>>>> Envoyé : 20 octobre 2011 11:50
>>>> À : OmnisDev List – English
>>>> Objet : O$5.1.1 Loading image file to a variable using HTTPRead.
>>>>
>>>> Hi all,
>>>>
>>>> Here is the problem:
>>>>
>>>> I need to get an image file from a web site and load it to a variable so
>>>> I can use it in an Omnis field.
>>>>
>>>> So far I came up with this code:
>>>>
>>>> HTTPSplitURL (ivPictureLink,lvHost,lvURI)
>>>> HTTPGet (lvHost,lvURI) Returns lvSocket
>>>> HTTPRead (lvSocket,ivBuffer,2) Returns lvByteCount
>>>> HTTPClose (lvSocket)
>>>>
>>>> ivPictureLink is the URI for the picture file on the webserver. It’s
>>>> something like that: eyeway.gr/picture.jpg
>>>> I managed to get the binary file loaded in to ivBuffer variable of
>>>> Binary type but is useless because it contains the HTTP header from the
>>>> server. Is there any way to eliminate the header and keep the binary
>>>> part of the response or even another way to do what I want to do? Please
>>>> note, I would like to avoid using FTP.
>>>>
>>>> Thanks in advance.
>>>>
>>>> George
>>>>
>>> _____________________________________________________________
>>> Manage your list subscriptions at lists.omnis-dev.com
>>
>> _____________________________________________________________
>> Manage your list subscriptions at lists.omnis-dev.com
>
> _____________________________________________________________
> Manage your list subscriptions at lists.omnis-dev.com
_____________________________________________________________
Manage your list subscriptions at lists.omnis-dev.com