{"id":27111013,"url":"https://github.com/thedgmbh/multi-rest","last_synced_at":"2025-04-07T00:54:40.992Z","repository":{"id":57305079,"uuid":"70199601","full_name":"thedgmbh/multi-rest","owner":"thedgmbh","description":"A middleware to handle multi-part request for restify","archived":false,"fork":false,"pushed_at":"2018-04-07T12:56:39.000Z","size":53,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-04T11:40:30.892Z","etag":null,"topics":["api","multi-rest","multipart","nodejs","npm","npm-package","restify"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/multi-rest","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/thedgmbh.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":"2016-10-06T22:58:14.000Z","updated_at":"2019-06-15T15:15:06.000Z","dependencies_parsed_at":"2022-09-20T20:45:15.065Z","dependency_job_id":null,"html_url":"https://github.com/thedgmbh/multi-rest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedgmbh%2Fmulti-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedgmbh%2Fmulti-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedgmbh%2Fmulti-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedgmbh%2Fmulti-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thedgmbh","download_url":"https://codeload.github.com/thedgmbh/multi-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256064,"owners_count":20909240,"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":["api","multi-rest","multipart","nodejs","npm","npm-package","restify"],"created_at":"2025-04-07T00:54:40.278Z","updated_at":"2025-04-07T00:54:40.983Z","avatar_url":"https://github.com/thedgmbh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi Rest v2\n\nMulti rest is a swiss knife for handling multi-part requests for [restify](http://restify.com), and as all Node.js frameworks use HTTP server at the end so I built this dealing with HTTP requests, this module can handle diffrent files and process them.\n\n| version 2 is received huge update from the last version with the thumbnails for images and videos \n\n## Features: \n\t- Path handler.\n\t- File naming. \n\t- Upload more then one file in the same request. \n\t- Thumbnails for images \u0026 videos.\n\t- S3 support for AWS.\n\t- Upload certain extensions.\n\n## In progress \n\t- Handling multiple files under the same fieldname.\n\t- ......\n\n\n[![NPM](https://nodei.co/npm/multi-rest.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/multi-rest/)\n\n#### Example for disk:\n\n```javascript\n\nconst restify = require('restify');\nconst Multi = require('multi-rest');\nconst uuid = require('uuid');\n\nvar server = restify.createServer();\n\nvar upload_disk = new Multi({\n    driver: {\n        type: 'local',\n        path: \"./uploads/\"\n    },\n    filename: (name) =\u003e { // the extention will be added automaticlly \n        return uuid.v4();\n    },\n    filefields: {\n        video: {\n            type: 'video',\n            thumbnail: {\n                width: 100,\n                time: ['10%'],\n                count: 1\n            },\n            required: false,\n            extensions: ['mp4']\n        },\n        image: {\n            type: 'picture',\n            thumbnail: {\n                width: 400,\n                height: 300\n            },\n            required: false,\n            extensions: ['png', 'jpg']\n        }\n    }\n});\n\nserver.use(restify.plugins.acceptParser(server.acceptable));\nserver.use(restify.plugins.queryParser());\nserver.use(restify.plugins.bodyParser());\n\nserver.post('/upload', upload_disk ,function (req, res, next){\n\tres.send({success: true, files: req.files, message: \"file uploaded :)\"});\n});\n\nserver.listen(8080, function() {\n  console.log('%s listening at %s', server.name, server.url);\n});\n\n```\n\n#### Example for s3:\n\ncheck how to configure [AWS-SDK](https://aws.amazon.com/sdk-for-node-js/) for Nodejs\n\nYou need to create AWS credentials to ~/.aws/credentials\n\n```\n[default]\n\naws_access_key_id = your_access_key\n\naws_secret_access_key = your_secret_key\n\n```\n#### Test code:\n\n```javascript\n\nconst restify = require('restify');\nconst Multi = require('multi-rest');\nconst uuid = require('uuid');\n\nvar server = restify.createServer();\n\nvar upload_s3 = new Multi({\n    driver: {\n        type: 's3',\n        endpoint: 's3-accelerate.amazonaws.com',\n        signatureVersion: 'v4',\n        region: 'eu-central-1',\n        bucketName: 'test',\n        path: ''\n    },\n    filename: (name) =\u003e { // the extention will be added automaticlly \n        return uuid.v4();\n    },\n    filefields: {\n        video: {\n            type: 'video',\n            thumbnail: {\n                height: 100,\n                time: ['10%', '40%'],\n                count: 2\n            },\n            required: false,\n            extensions: ['mp4']\n        },\n        image: {\n            type: 'picture',\n            thumbnail: {\n                width: 400,\n                height: 300\n            },\n            required: false,\n            extensions: ['png', 'jpg']\n        }\n    }\n});\n\nserver.use(restify.acceptParser(server.acceptable));\nserver.use(restify.queryParser());\nserver.use(restify.bodyParser());\nserver.use(restify.CORS());\n\nserver.post('/upload', upload ,function (req, res, next){\n\tres.send({success: true, files: req.files, message: \"file uploaded :)\"});\n});\n\nserver.listen(8080, function() {\n  console.log('%s listening at %s', server.name, server.url);\n});\n\n```\n\n#### File naming\n\n##### Random \nThis uses a `uuid` v4 library to create the file name\n```javascript\nfunction (name) { \n    return uuid.v4();\n}\n```\n##### Same name \nThis uses the name of the uploaded file .\n```javascript\nfunction (name) { \n    return name;\n}\n```\n##### Plus date\nThis will add file upload timestamp after the file name.\n```javascript\nfunction (name) { \n    return name + new Date();\n}\n```\n##### Date\nThis use `new Date()` to create the file name (not prefered when uploading more then one file)\n```javascript\nfunction (name) { \n    return new Date();\n}\n```\n#### License\nLicensed under MIT\n\n#### Author\nM. Mahrous developed at [The D. GmbH](https://thed.io)\nFeel free to contact me [M. Mahrous](mailto:m.mahrous@thed.io) and improve the code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedgmbh%2Fmulti-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthedgmbh%2Fmulti-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedgmbh%2Fmulti-rest/lists"}