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 
Switch to threaded view of this topic Create a new topic Submit Reply
Help with IDLnetURL [message #85212] Sun, 14 July 2013 08:05 Go to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
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()
Re: Help with IDLnetURL [message #85226 is a reply to message #85212] Wed, 17 July 2013 07:58 Go to previous messageGo to next 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.
Re: Help with IDLnetURL [message #85227 is a reply to message #85212] Wed, 17 July 2013 08:36 Go to previous messageGo to next message
andrew.p.walsh is currently offline  andrew.p.walsh
Messages: 4
Registered: July 2013
Junior Member
From what I remember the CAA sends the filename as part of the response header, which you can get like this:

oURL -> GetProperty, response_header = header

where 'header' will just be a string that you can then search for the filename.
Re: Help with IDLnetURL [message #85228 is a reply to message #85227] Wed, 17 July 2013 08:39 Go to previous messageGo to next message
andrew.p.walsh is currently offline  andrew.p.walsh
Messages: 4
Registered: July 2013
Junior Member
Oh, and I forgot to say to call the above after the oURL -> Get(), so you'd still need to use a temporary file name in the Get().

On Wednesday, July 17, 2013 5:36:48 PM UTC+2, andrew....@gmail.com wrote:
> From what I remember the CAA sends the filename as part of the response header, which you can get like this:
>
>
>
> oURL -> GetProperty, response_header = header
>
>
>
> where 'header' will just be a string that you can then search for the filename.
Re: Help with IDLnetURL [message #85268 is a reply to message #85228] Fri, 19 July 2013 16:26 Go to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Thanks a lot! I will try this.
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 13:39:25 PDT 2025

Total time taken to generate the page: 0.00512 seconds