{"id":21224076,"url":"https://github.com/kodie/form-data-body","last_synced_at":"2025-07-10T14:31:15.348Z","repository":{"id":57144396,"uuid":"341385693","full_name":"kodie/form-data-body","owner":"kodie","description":"A tiny, dependency-free node module for generating a form's multipart/form-data body for a POST request.","archived":false,"fork":false,"pushed_at":"2023-01-06T19:55:54.000Z","size":107,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-11T12:36:45.732Z","etag":null,"topics":["body","boundary","data","fields","form","formdata","generate","multipart","node","nodejs","parse","post","request"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kodie.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-23T01:06:48.000Z","updated_at":"2023-10-05T12:53:34.000Z","dependencies_parsed_at":"2023-02-06T08:31:00.235Z","dependency_job_id":null,"html_url":"https://github.com/kodie/form-data-body","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fform-data-body","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fform-data-body/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fform-data-body/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fform-data-body/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kodie","download_url":"https://codeload.github.com/kodie/form-data-body/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225640771,"owners_count":17501018,"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":["body","boundary","data","fields","form","formdata","generate","multipart","node","nodejs","parse","post","request"],"created_at":"2024-11-20T22:54:56.773Z","updated_at":"2024-11-20T22:54:57.330Z","avatar_url":"https://github.com/kodie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# form-data-body\n\n[![npm package version](https://img.shields.io/npm/v/form-data-body.svg?style=flat-square)](https://www.npmjs.com/package/form-data-body)\n[![Travis build status](https://img.shields.io/travis/com/kodie/form-data-body.svg?style=flat-square)](https://travis-ci.com/kodie/form-data-body)\n[![npm package downloads](https://img.shields.io/npm/dt/form-data-body.svg?style=flat-square)](https://www.npmjs.com/package/form-data-body)\n[![code style](https://img.shields.io/badge/code_style-standard-yellow.svg?style=flat-square)](https://github.com/standard/standard)\n[![license](https://img.shields.io/github/license/kodie/form-data-body.svg?style=flat-square)](license.md)\n\nA tiny, dependency-free node module for generating a form's multipart/form-data body for a POST request.\n\nThis is meant to be a simple, no frills module for generating a string to send as the body for a POST request, simulating a form submission. If you need something with more bells and whistles, check out the [form-data](https://github.com/form-data/form-data) module.\n\n## Installation\n\n```shell\nnpm install --save form-data-body\n```\n\n## Usage\n\n```js\nconst formDataBody = require('form-data-body')\n\n// Specify form fields\nconst fields = {\n  name: 'My test post',\n  description: 'This is just a test post',\n  items: ['First Item', 'Second Item'],\n\n  // Files should be an object with the name, type, and data set to strings\n  image: {\n    name: 'hello.jpg',\n    type: 'image/jpeg',\n    data: binaryImageData\n  }\n}\n\nconst boundary = formDataBody.generateBoundary()\nconst header = {\n  'Content-Type': `multipart/form-data; boundary=${boundary}`\n}\nconst body = formDataBody(fields, boundary)\n```\n\n### Example Response\n\n```\n----------------------------071517909670537006900435\nContent-Disposition: form-data; name=\"name\"\n\nMy test post\n----------------------------071517909670537006900435\nContent-Disposition: form-data; name=\"description\"\n\nThis is just a test post\n----------------------------071517909670537006900435\nContent-Disposition: form-data; name=\"items[]\"\n\nFirst Item\n----------------------------071517909670537006900435\nContent-Disposition: form-data; name=\"items[]\"\n\nSecond Item\n----------------------------071517909670537006900435\nContent-Disposition: form-data; name=\"image\"; filename=\"hello.jpg\"\nContent-Type: image/jpeg\n\n[BINARY IMAGE DATA]\n----------------------------071517909670537006900435--\n```\n\n## License\nMIT. See the [license.md file](license.md) for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodie%2Fform-data-body","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkodie%2Fform-data-body","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodie%2Fform-data-body/lists"}