O$5.1.1 Loading image file to a variable using HTTPRead.
Has anyone an easier, more workable solution to retrieving an image from a website please?
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?
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: firstname.lastname@example.org <mailto:email@example.com>
> On 24 Oct 2011, at 00:33, George Panagopoulos <firstname.lastname@example.org> 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.
> 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(
>> Mark Watson
>> —–Message d’origine—–
>> De : email@example.com
>> [mailto:firstname.lastname@example.org] De la part de George
>> 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.
> Manage your list subscriptions at lists.omnis-dev.com
Manage your list subscriptions at lists.omnis-dev.com