{"id":22296432,"url":"https://github.com/knowledgecode/formdatabuilder","last_synced_at":"2025-07-25T02:08:04.818Z","repository":{"id":29100394,"uuid":"32629719","full_name":"knowledgecode/formdatabuilder","owner":"knowledgecode","description":"An alternative FormData object for Web Workers","archived":false,"fork":false,"pushed_at":"2015-06-22T14:59:18.000Z","size":428,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T02:42:55.036Z","etag":null,"topics":[],"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/knowledgecode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-21T11:23:03.000Z","updated_at":"2022-03-30T07:07:15.000Z","dependencies_parsed_at":"2022-09-05T10:22:34.685Z","dependency_job_id":null,"html_url":"https://github.com/knowledgecode/formdatabuilder","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowledgecode%2Fformdatabuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowledgecode%2Fformdatabuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowledgecode%2Fformdatabuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knowledgecode%2Fformdatabuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knowledgecode","download_url":"https://codeload.github.com/knowledgecode/formdatabuilder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245556976,"owners_count":20634888,"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":[],"created_at":"2024-12-03T17:45:34.343Z","updated_at":"2025-03-25T22:37:16.199Z","avatar_url":"https://github.com/knowledgecode.png","language":"JavaScript","readme":"# FormDataBuilder [![Circle CI](https://circleci.com/gh/knowledgecode/formdatabuilder.svg?style=shield)](https://circleci.com/gh/knowledgecode/formdatabuilder)\r\nThis is an alternative [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) object in Web Workers. It's not a polyfill, but it has similar interface and can be created blob to send via XHR2.  \r\n## WHY\r\nWhen we upload files via multipart/form-data, `FormData` object is very useful. However according to my investigation, in Web Workers it seems not to be able to use it except Chrome for now. It would be better if could create the polyfill, but it's probably impossible because at least there is a problem with converting to string from binary.  \r\n## API\r\n### Constructor\r\n```javascript\r\nvar form = new FormDataBuilder();\r\n```\r\n### append(name, value)\r\n```javascript\r\nform.append('name', 'John Smith');\r\nform.append('photo', file);\r\n```\r\n### getBlob()\r\n```javascript\r\nvar blob = form.getBlob();\r\n```\r\n### type\r\n```javascript\r\nxhr.setRequestHeader('Content-Type', form.type);\r\n```\r\n## Example\r\n```javascript\r\nimportScripts('FormDataBuilder.js');\r\n\r\nself.onmessage = function (evt) {\r\n    var profile = evt.data,\r\n        form = FormData ? new FormData() : new FormDataBuilder();\r\n\r\n    form.append('name', profile.name);      // =\u003e String\r\n    form.append('email', profile.email);    // =\u003e String\r\n    form.append('photo', profile.file);     // =\u003e File\r\n\r\n    var xhr = new XMLHttpRequest(),\r\n        url = 'http://example.com/upload';\r\n\r\n    xhr.onload = function () {\r\n        if (xhr.readyState === 4) {\r\n            if (xhr.status === 200) {\r\n                postMessage(xhr.responseText);\r\n            } else {\r\n                postMessage('error');\r\n            }\r\n        }\r\n    };\r\n    xhr.open('POST', url, true);\r\n    if (form.type) {\r\n        xhr.setRequestHeader('Content-Type', form.type);\r\n    }\r\n    xhr.send(form.getBlob ? form.getBlob() : form);\r\n};\r\n```\r\n## Browser Support\r\nChrome, Android 4.4+, Firefox, Safari 6+, Opera, and Internet Explorer 10+.  \r\n## License\r\nMIT  \r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknowledgecode%2Fformdatabuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknowledgecode%2Fformdatabuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknowledgecode%2Fformdatabuilder/lists"}