Problems downloading file from webserver

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Locked
dbailey
Posts: 23
Joined: Fri Sep 06, 2013 4:47 pm

Problems downloading file from webserver

Post by dbailey » Mon Sep 23, 2013 3:37 pm

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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Problems downloading file from webserver

Post by Simon » Mon Sep 23, 2013 7:41 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dbailey
Posts: 23
Joined: Fri Sep 06, 2013 4:47 pm

Re: Problems downloading file from webserver

Post by dbailey » Tue Oct 01, 2013 10:53 am

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

dbailey
Posts: 23
Joined: Fri Sep 06, 2013 4:47 pm

Re: Problems downloading file from webserver

Post by dbailey » Tue Oct 01, 2013 12:18 pm

I have now fixed this also :D

I needed:-

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


This is now working.

Locked

Return to “Summer School 2013”