{"id":13896367,"url":"https://github.com/catwell/lua-multipart-post","last_synced_at":"2025-04-13T21:32:41.362Z","repository":{"id":5674832,"uuid":"6884657","full_name":"catwell/lua-multipart-post","owner":"catwell","description":"HTTP Multipart Post helper that does just that.","archived":false,"fork":false,"pushed_at":"2023-01-11T16:32:32.000Z","size":29,"stargazers_count":43,"open_issues_count":0,"forks_count":23,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T11:17:30.630Z","etag":null,"topics":["http","lua","luasocket","multipart"],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catwell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-27T14:24:40.000Z","updated_at":"2024-09-06T00:13:59.000Z","dependencies_parsed_at":"2023-01-13T13:39:21.225Z","dependency_job_id":null,"html_url":"https://github.com/catwell/lua-multipart-post","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catwell%2Flua-multipart-post","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catwell%2Flua-multipart-post/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catwell%2Flua-multipart-post/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catwell%2Flua-multipart-post/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catwell","download_url":"https://codeload.github.com/catwell/lua-multipart-post/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248786235,"owners_count":21161420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","lua","luasocket","multipart"],"created_at":"2024-08-06T18:02:52.044Z","updated_at":"2025-04-13T21:32:41.340Z","avatar_url":"https://github.com/catwell.png","language":"Lua","readme":"# multipart-post\n\n![CI Status](https://github.com/catwell/lua-multipart-post/actions/workflows/ci.yml/badge.svg?branch=master)\n\n## Presentation\n\nHTTP Multipart Post helper that does just that.\n\n## Dependencies\n\nThe module itself only depends on luasocket (for ltn12).\n\nTests require [cwtest](https://github.com/catwell/cwtest), a JSON parser\nand the availability of [httpbin.org](http://httpbin.org).\n\n## Usage\n\n```lua\nlocal mp = require \"multipart-post\"\nlocal http = require \"socket.http\"\n\nlocal rq = mp.gen_request({myfile = {name = \"myfilename\", data = \"some data\"}})\nrq.url = \"http://httpbin.org/post\"\nlocal b, c, h = http.request(rq)\n```\n\nSee [LuaSocket](http://w3.impa.br/~diego/software/luasocket/http.html)'s\n`http.request` (generic interface) for more information.\n\nIf you only need to get the multipart/form-data body use `encode`:\n\n```lua\nlocal body, boundary = mp.encode({foo = \"bar\"})\n-- use `boundary` to build the Content-Type header\n```\n\n## Advanced Usage\n\nExample using ltn12 streaming via file handles\n\n```lua\nlocal file = io.open(\"myfilename\", \"r\")\nlocal file_length = file:seek(\"end\")\nfile:seek(\"set\", 0)\n\nlocal rq = mp.gen_request({\n    myfile = {\n        name = \"myfilename\",\n        data = file,\n        len = file_length,\n    }\n})\n```\n\nExample using ltn12 source streaming\n\n```lua\nlocal ltn12 = require \"socket.ltn12\"\n\nlocal rq = mp.gen_request({\n    myfile = {\n        name = \"myfilename\",\n        data = ltn12.source.string(\"some data\"),\n        len = string.len(\"some data\"),\n    }\n})\nrq.url = \"http://httpbin.org/post\"\nlocal b, c, h = http.request(rq)\n```\n\n## Bugs\n\nNon-ASCII part names are not supported.\nAccording to [RFC 2388](http://tools.ietf.org/html/rfc2388):\n\n\u003e Note that MIME headers are generally required to consist only of 7-\n\u003e bit data in the US-ASCII character set. Hence field names should be\n\u003e encoded according to the method in\n\u003e [RFC 2047](http://tools.ietf.org/html/rfc2047) if they contain\n\u003e characters outside of that set.\n\nNote that non-ASCII file names are supported since version 1.2.\n\n## Contributors\n\n- Pierre Chapuis ([@catwell](https://github.com/catwell))\n- Cédric Deltheil ([@deltheil](https://github.com/deltheil))\n- TJ Miller ([@teejaded](https://github.com/teejaded))\n- Rami Sabbagh ([@RamiLego4Game](https://github.com/RamiLego4Game))\n- [@Gowa2017](https://github.com/Gowa2017)\n\n## Copyright\n\n- Copyright (c) 2012-2013 Moodstocks SAS\n- Copyright (c) 2014-2022 Pierre Chapuis\n","funding_links":[],"categories":["Lua"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatwell%2Flua-multipart-post","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatwell%2Flua-multipart-post","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatwell%2Flua-multipart-post/lists"}