Page 1 of 1

Problems downloading file from webserver

Posted: Mon Sep 23, 2013 3:37 pm
by dbailey
Hi All,

Nearly finished my Summer School Project :D but have a problem downloading from a webserver I'm using some code found within the Apps Academy on how to download html or a file. My code is:-

on mouseUp
put the selectedtext of field "Video List" into theVideoFileName
set the itemDel to "/"
ask file "Save file as:" with selectedtext of field "Video List"
if it is empty then exit mouseUp
put "http://webserver/folder/" & theVideoFileName into VideoUrl
put VideoURL into URL ("file:" & it)
end mouseUp

All the above does is download a 56bytes file named as I have requested but not the full file (Which is a .mov file)

Any ideas?, I have tried a binfile also, same result.

Re: Problems downloading file from webserver

Posted: Mon Sep 23, 2013 7:41 pm
by Simon
Hi,
Here is a debug test:
Take the URL you get from the VideoUrl variable and paste into your browser, see what you get.

If you get the same 56 bytes then everything is working as it should. Now of course your URL maybe incorrect... That would be the place to start looking.

It sounds like you are getting a 404 error page (really small)

One thing to watch out for is spaces and special characters in the URL you may have to URLEncode the url before using it.

Simon

Re: Problems downloading file from webserver

Posted: Tue Oct 01, 2013 10:53 am
by dbailey
Thanks for the reply, I've checked the url as suggested when pasted into a browser the .jpg or .mov file displays or plays the file so it seems the url is correct. I have also checked for any spaces in the url. My code now looks like this:

on mouseUp
global playlistURL
put the selectedtext of field "Video List" into theVideoFileName
replace space with "%20" in theVideoFileName

set the itemDel to slash
ask file "Save file as:" with selectedtext of field "Video List"

put playlistURL & theVideoFileName into VideoUrl

put VideoURL into URL ("file:" & it)
end mouseUp

Re: Problems downloading file from webserver

Posted: Tue Oct 01, 2013 12:18 pm
by dbailey
I have now fixed this also :D

I needed:-

put URL VideoURL into URL ("binfile:" & it)


This is now working.