LoginSignup
0
0

More than 5 years have passed since last update.

FlashAir の Lua で Basic 認証 POST リクエスト

Posted at
boundary = "--61141483716826"
contenttype = "multipart/form-data; boundary=" .. boundary
filepath = "/cat.jpg"
mes = "--".. boundary .. "\r\n"
 .."Content-Disposition: form-data; name=\"image\"; filename=\"cat.jpg\"\r\n"
 .."Content-Type: image/jpeg\r\n"
 .."\r\n"
 .."<!--WLANSDFILE-->\r\n"
 .."--" .. boundary .. "--\r\n"

blen = lfs.attributes(filepath, "size") + string.len(mes) - 17
b, c, h = fa.request{url = "http://example.com",
  method = "POST",
  headers = {["Authorization"] = "Basic user:passwordをBase64した値",
  ["Content-Length"] = tostring(blen),
  ["Content-Type"] = contenttype},
  file = filepath,
  body = mes
}

print(b)
print("\n")

リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0