Page 1 of 1

Mangled URL File Download

Posted: Thu Feb 09, 2012 11:28 pm
by Simon Knight
I am attempting to create an application that will down load a Google Earth KMZ file and load it into the Google Earth application. The target KMZ file is stored on a server connected to the internet.

I have put the target file's URL into a field named fldMyURL. If I use the line

Code: Select all

launch url  fld"fldMyURL"
the URL is passed to my default browser, Safari, and the file downloads to my downloads folder. Double clicking on the file causes it to open in Google Earth and display the points of interest. However, if I use the line

Code: Select all

put url fld"fldMyURL"  into URL"file:lkp.kmz"
then a file is written to the default folder but it is slightly different and does not load correctly into Google Earth.

Examining the two file in a hex editor shows that they are different lengths and that the corrupted file has a type creator set as TXET/txtt whereas the working file has no type data.

I have also tried the command libURLDownloadToFile but I could not get it to work i.e nothing was downloaded.

Any ideas as to what is going wrong?

best wishes
Simon

Re: Mangled URL File Download

Posted: Thu Feb 09, 2012 11:56 pm
by bn
Hi Simon,

good to 'see' you.

you might want to try binfile as in

Code: Select all

put url fld"fldMyURL" into URL "binfile:lkp.kmz"
if you only use "file:" the file is treated as text file and is transformed to fit the operating system. E.g the line endings are operating system specific, high ascii characters are operating specific etc.

binfile saves it as binary file without change. See URL in the documentation.

Kind regards

Bernd

Re: Mangled URL File Download

Posted: Fri Feb 10, 2012 12:03 am
by Simon Knight
Hi Bernd,

Its good to be back! I feel that I should have known this one. Thanks, it works (of course!).

I also managed to get the

Code: Select all

libURLDownLoadToFile fld"fldMyURL", tFilePath & "/lkp2.kmz"
to work once I correctly specified the filepath, this command defaults to binary.

best wishes
Simon