comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Help with IDLnetURL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Help with IDLnetURL [message #85226 is a reply to message #85212] Wed, 17 July 2013 07:58 Go to previous messageGo to previous message
Rob Klooster is currently offline  Rob Klooster
Messages: 18
Registered: February 2013
Junior Member
Op zondag 14 juli 2013 17:05:51 UTC+2 schreef Matthew Argall het volgende:
> All,
>
>
>
> I am trying to use the IDLnetURL class to retrieve data from an HTTP site. The documentation on the host says it will return either a Zip file containing the data or a Text file named CAA_Error.log.x, depending on whether an error occurred or not. The problem is that IDL changes the filename of the saved file to 'idl.dat', or to whatever I specify with the FILENAME keyword. Is there any way to determine which file type has been retrieved and to name it accordingly?
>
>
>
> The scheme they give is this:
>
> url = ' http://caa.estec.esa.int/caa_query/?key1=value1&key2=val ue2&...'
>
>
>
> So, what I am doing is:
>
>
>
> oURL = Obj_New('IDLnetURL')
>
> oURL -> SetProperty, URL_SCHEME='http', URL_HOST='caa.estec.esa.int'
>
>
>
> [Widget to get input from user (i.e. username, password, etc.)]
>
>
>
> oURL -> SetProperty, URL_PATH='caa_query/?key1=value1&key2=value2&...'
>
>
>
> fname_returned = oURL -> Get()

You could save a temporary copy, read in the first couple of bytes from the file and compare it to the magic number for ZIP files (see http://www.digitalpreservation.gov/formats/fdd/fdd000354.sht ml under file signatures)

bytes = bytarr(4)
openr, lun, filename, /get_lun
readu, lun, bytes
free_lun, lun

If the bytes array is equal to [80b,75b,1b,2b], [80b,75b,3b,4b], [80b,75b,5b,6b] or [80b,75b,7b,8b] then it is a ZIP file, otherwise it is probably the plain text file.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Open text files consecutively without knowing names
Next Topic: Re: IDL 8.2, read pixel value along a surface

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:46:48 PDT 2025

Total time taken to generate the page: 1.19571 seconds