{"id":19005799,"url":"https://github.com/robert-kratz/busboy-upload","last_synced_at":"2026-05-06T18:31:21.134Z","repository":{"id":37494297,"uuid":"505930900","full_name":"robert-kratz/busboy-upload","owner":"robert-kratz","description":"This express middleware is handling fileuploads on top of connect-busboy. ","archived":false,"fork":false,"pushed_at":"2022-06-24T09:58:05.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T11:36:41.792Z","etag":null,"topics":["busboy","expressjs","fileupload","middleware"],"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/robert-kratz.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":"2022-06-21T16:55:04.000Z","updated_at":"2022-06-21T20:10:22.000Z","dependencies_parsed_at":"2022-09-07T12:02:41.783Z","dependency_job_id":null,"html_url":"https://github.com/robert-kratz/busboy-upload","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robert-kratz/busboy-upload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-kratz%2Fbusboy-upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-kratz%2Fbusboy-upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-kratz%2Fbusboy-upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-kratz%2Fbusboy-upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robert-kratz","download_url":"https://codeload.github.com/robert-kratz/busboy-upload/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-kratz%2Fbusboy-upload/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274719637,"owners_count":25337237,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["busboy","expressjs","fileupload","middleware"],"created_at":"2024-11-08T18:29:13.283Z","updated_at":"2026-05-06T18:31:21.102Z","avatar_url":"https://github.com/robert-kratz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# busboy-upload\nThis express middleware is handling fileuploads on top of connect-busboy. It provides an simple solution to deal with large files.\n\n```\n$ npm install busboy-upload\n```\n\n## Content\n\n - \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\n - \u003ca href=\"#api-response\"\u003eAPI Response\u003c/a\u003e\n - \u003ca href=\"#set-up-the-middleware\"\u003eSet up the express middleware\u003c/a\u003e\n - \u003ca href=\"#file-object\"\u003eInformations about the uploaded file\u003c/a\u003e\n - \u003ca href=\"#errors\"\u003eError Handling\u003c/a\u003e\n - \u003ca href=\"#test-your-code-with-axios\"\u003eTest your code\u003c/a\u003e\n\n## Usage\n\nFirst of all, we need to define the callbacks to get informations about the upload\n\n```js\n/**\n * Is fired when file has been successfully uploaded\n * @param {Object} fileInfo \n */\nconst success = (file) =\u003e {\n\n    console.log(file.stats); // { total: 20, error: 10, success: 10 }\n    console.log(file.files); // Array of all files\n    console.log(file.duration); //file upload duration in ms\n    \n}\n\nconst config = {\n    uploadPath: __dirname + '/uploads/',\n    uploadName: Date.now(),\n    maxSize: 100000,\n    mimeTypes: ['image/jpeg'], // Take a look into all aviable mime types here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\n    maxsize: 100000, // In bytes\n    filter: (file, deny) =\u003e {\n        if(file.originalFile.filename == 'test.jpesg') return deny('INVALID_BIT_AMOUNT'); // Method needs to be returned!\n    },\n    onlyRead: true // Only reads the incoming form-data, appends an parameter chunks to file as a Buffer of the file content\n}\n```\n\nNote: If you do not want to apply a filter, just leave the config parameter blanc.\n\nThe parameter `file` in filter will have the format like \u003ca href=\"#file-has-been-successfully-uploaded\"\u003ethis\u003c/a\u003e.\n\n## API Response\n\n```js\n{\n  stats: { total: 20, error: 10, success: 10 },\n  files: [],\n  duration: 1041 //in ms\n}\n```\n\n## Set up the middleware\n\nThe API needs to be included in one of the express Routers:\n\n```js\nconst busboy = require('busboy');\nconst fileUpload = require('busboy-upload');\n\napp.use(busboy({ immediate: true }));\n\napp.use('/upload', (req, res) =\u003e {\n\n  // Callbacks from above\n  \n  fileUpload(req, success, config);\n});\n```\n\n## File Object\n\n### File has been successfully uploaded:\n\n```js\n{\n  errors: [],\n  originalFile: {\n    filename: 'test.jpeg',\n    encoding: '7bit',\n    mimeType: 'image/jpeg',\n    uploadedPath: 'uploads/file9-test.jpeg-1655893178067.jpeg'\n  },\n  uploadedFile: {\n    uploadedName: 'file9-test.jpeg-1655893178067',\n    uploadedPath: 'uploads/file9-test.jpeg-1655893178067.jpeg',\n    uploadDuration: 1,\n    success: true,\n    fileInfo: {\n      _readableState: [Object],\n      _events: {},\n      _eventsCount: 0,\n      truncated: false,\n      _readcb: null\n    },\n    size: 89090\n  }\n}\n```\n\n### File has been not been successfully uploaded:\n\n```js\n{\n  errors: [ 'FILE_TYPE_NOT_ALLOWED' ],\n  originalFile: {\n    filename: 'bomb.zip',\n    encoding: '7bit',\n    mimeType: 'application/zip'\n  },\n  uploadedFile: {\n    uploadedName: 'bomb9-bomb.zip-1655893178067',\n    uploadedPath: 'uploads/bomb9-bomb.zip-1655893178067.zip',\n    uploadDuration: 0,\n    success: false,\n    fileInfo: {\n      _readableState: [Object],\n      _events: {},\n      _eventsCount: 0,\n      truncated: false,\n      _readcb: null\n    }\n  }\n}\n```\n\nNote: The file size is provided in Bytes\n\n\n## Errors\nThe parameter `error` of a file returns one of these following errors. In the table below, you can learn how to deal with errors\n\nError | Meaning\n--- | ---\nFILE_TYPE_NOT_ALLOWED | The filetype does not match the provided query\nUPLOADED_FILE_TO_BIG | The provided file exeedes the provided limit of bytes \nMAXIMUM_FILE_AMOUNT_REACHED | The maximum file size has been reached, no files after the limit will be uploaded\nFILE_TYPE_NOT_ALLOWED | The mime type is not allowed to be uploaded\n\nNote: Other errors could occoure, in this case you probably did something wrong whith the config, open a \u003ca href=\"https://github.com/robert-kratz/busboy-upload/issues\"\u003enew issues\u003c/a\u003e\n\n## Test your code with axios\n\nTo test your code, you can start uploading file with \u003ca href=\"https://github.com/axios/axios\"\u003eaxios\u003c/a\u003e. For that, you need to have \u003ca href=\"https://www.npmjs.com/package/form-data\"\u003eform-data\u003c/a\u003e, \u003ca href=\"https://nodejs.org/api/fs.html\"\u003efs\u003c/a\u003e and \u003ca href=\"https://www.npmjs.com/package/axios\"\u003eaxios\u003c/a\u003e installed, you can do that by running:\n\n```\n$ npm install fs form-data axios\n```\n\n### Sample code:\n\n```js\n\nconst formData = require('form-data');\nconst fs = require('fs');\n\nconst axios = require('axios').default;\n\nconst init = async () =\u003e {\n    const fd = new formData();\n\n    fd.append('cat', fs.createReadStream('./miau.jpeg'));\n    fd.append('dog', fs.createReadStream('./dog.jpeg'));\n\n    const res = await axios.post('http://127.0.0.1:443/upload', fd, {\n        maxBodyLength: Infinity,\n        maxContentLength: Infinity,\n            headers: {\n                ...fd.getHeaders()\n            }\n    }).then(res =\u003e {\n        console.log(res.data);\n    }).catch(err =\u003e console.log(err));\n}\n\ninit();\n```\n\n Made by \u003ca href=\"https://github.com/robert-kratz\"\u003eRobert J. Kratz\u003c/a\u003e\n \n ## License\n \n MIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobert-kratz%2Fbusboy-upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobert-kratz%2Fbusboy-upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobert-kratz%2Fbusboy-upload/lists"}