Skip to content

uriid1/lua-multipart-post

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

multipart-post

Presentation

HTTP Multipart Post helper that does just that.

Usage

local multipart_encode = require("multipart-post")
local ltn12 = require("ltn12")
local https = require("ssl.https")
	
-- Send Telegram message from bot
local request_body = {
	chat_id = CHAT_ID;
	text = "Hello World!";
}


-- Make request
local body, boundary = multipart_encode(request_body)

https.request {
    url = "https://api.telegram.org/bot" .. BOT_TOKEN .. "/sendMessage",
    method = "POST",
    headers = {
        ["Content-Type"] = "multipart/form-data; boundary=" .. boundary,
        ["Content-Length"] = #body,
    },
    source = ltn12.source.string(body),
}

About

HTTP Multipart Post helper that does just that.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua 100.0%