1 -- *********************************************************************
3 -- *********************************************************************
5 -- Détermination de la taille d'un fichier
6 function wsls_fsize (name)
7 fso = io.open(name, "r")
13 -- Détermination de l'extension d'un fichier
14 function wsls_fext (name)
15 return string.match(name, "(%.%a+)$")
18 -- Détermination du fichier
19 function wsls_fname (tail)
20 return string.match(tail, "/?([%a%d%.%-]+)$")
24 function wsls_get (base, tail)
25 http = require("socket.http")
26 ltn12 = require("ltn12")
27 file = wsls_fname(tail)
28 out = io.open(file, "w")
29 r, c, h = http.request {
30 url = "http://" .. base .. tail,
31 sink = ltn12.sink.file(out)
34 print ("Le fichier " .. file .. "(" ..
35 wsls_fsize(file) .. " octets) est transféré !")
41 function wsls_put (base, tail)
42 http = require("socket.http")
43 ltn12 = require("ltn12")
44 file = wsls_fname(tail)
45 r, c, h = http.request {
47 url = "http://" .. base .. tail,
48 source = ltn12.source.file(io.open(file)),
50 ["content-length"] = wsls_fsize(file)
54 print ("Le fichier " .. file .. "(" ..
55 wsls_fsize(file) .. " octets) est transféré !")