--当然ですが、Wi-Fi接続されている時でないと動きません
--ファイル名はUTF-8かつURLエンコードが必要です。
--はい、ここではそれをやっていないため、日本語名や、空白入りのファイル名なんかを入れると、
--おそらくDropboxから拒否られます。
fp=io.open("log.txt","r")
if not fp then
fp=io.open("log.txt","w")
fp:write("files = {}")
end
io.close(fp)
dofile("log.txt") --ファイルがないと死ぬ。関数に入れても死ぬ。Luaの最初に置け
DIR = "/upload"
fp=io.open("log.txt","w")
fp:write("files = {}\n")
--走査
for file in lfs.dir(DIR) do
if file ~= "." and file ~= ".." then
fsize = lfs.attributes(DIR.."/"..file, "size")
dat = "files[\""..file.."\"]="..fsize.."\n"
if(files[file] ~= fsize) then
mes = "<!--WLANSDFILE-->"
len_s = lfs.attributes(DIR.."/"..file,"size")
hed = {["Content-Length"] = len_s,
["Authorization"] = "Bearer アクセストークン"}
print("CODE:")
b,c,h = fa.request{
url = "https://api-content.dropbox.com/1/files_put/auto/Lua/"..file,
method = "PUT",headers = hed,body = mes,file = DIR.."/"..file
}
print(c)
end
fp:write(dat)
print( file )
print(" ")
print(fsize)
print("<br>")
end
end
io.close(fp)
コメントをかく