starts function and little change on download_to_file

This commit is contained in:
yago 2015-02-02 22:22:05 +01:00
parent 737738a330
commit d012c26fa6

View File

@ -42,8 +42,7 @@ function download_to_file( url , noremove )
local respbody = {} local respbody = {}
one, c, h = http.request{url=url, sink=ltn12.sink.table(respbody), redirect=true} one, c, h = http.request{url=url, sink=ltn12.sink.table(respbody), redirect=true}
htype = h["content-type"] htype = h["content-type"]
vardump(c)
print("content-type: "..htype)
if htype == "image/jpeg" then if htype == "image/jpeg" then
file_name = string.random(5)..".jpg" file_name = string.random(5)..".jpg"
file_path = "/tmp/"..file_name file_path = "/tmp/"..file_name
@ -191,3 +190,8 @@ end
function string:isempty() function string:isempty()
return self == nil or self == '' return self == nil or self == ''
end end
function string.starts(String, Start)
return Start == string.sub(String,1,string.len(Start))
end