How to handle 307 temporary redirect?

I wrote an app that (wish to) downloads all the covers of my audio library albums.
From artist and album tags i search the coverartarchive.org and parse the html, but when i got the jpeg location from the mdib i got something like this:
See: http://archive.org/download/mbid-6ed7b940-99b2-3e8f-b624-114cc96165f4/mbid-6ed7b940-99b2-3e8f-b624-114cc96165f4-17000904511.jpg

but downloading http://archive.org/download/mbid-6ed7b940-99b2-3e8f-b624-114cc96165f4/mbid-6ed7b940-99b2-3e8f-b624-114cc96165f4-17000904511.jpg do not works 'case real url is redirected from archive.org servers to:
http://ia800607.us.archive.org/12/items/mbid-6ed7b940-99b2-3e8f-b624-114cc96165f4/mbid-6ed7b940-99b2-3e8f-b624-114cc96165f4-17000904511.jpg

i do not know how to handle the temporary redirect … so my downloaded jpg is 0 bytes …

Hello, every app developer is welcome, but your question is too short and cannot be answered. It just depends on the programming language you wrote the app in. Maybe search/ask a general developer forum dedicated to your programming language instead:

thanks yVanzo.
I was asking because i wrote apps in GAMBAS (http://gambas.sourceforge.net/en/main.html) and apis are for java or C/C++ i both hate a lot :smiley:

just joking, but i asked to the language forum and they proposed me to write a wrapper to the C api … too complex for me.

so i wonder if there was an “easy” way to ask the server the REAL (not redirected) URL for the picture?

AFAIK, there is no other way than supporting download redirects. Fortunately, all you need for this is the class HttpClient (gb.net.curl). The property Code can be checked for HTTP status 307. And the redirected URL can be retrieved by looking at the property Headers for the Location field.

3 Likes

YOU ARE MY SAVIOUR!!!
i got a 302 not 307, but I GOT THAT info in the header!!!

REALLY really thanks a lot!!!

1 Like