{"id":23665915,"url":"https://github.com/matter-in-motion/mm-file","last_synced_at":"2025-12-08T12:30:13.709Z","repository":{"id":57299110,"uuid":"116449886","full_name":"matter-in-motion/mm-file","owner":"matter-in-motion","description":"File uploads and processing resource extension","archived":false,"fork":false,"pushed_at":"2018-11-25T01:31:24.000Z","size":368,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T06:36:47.648Z","etag":null,"topics":["api","extension","formdata","matter-in-motion","processor","resources"],"latest_commit_sha":null,"homepage":null,"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/matter-in-motion.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":"2018-01-06T03:26:06.000Z","updated_at":"2018-11-25T01:31:23.000Z","dependencies_parsed_at":"2022-08-26T18:02:33.476Z","dependency_job_id":null,"html_url":"https://github.com/matter-in-motion/mm-file","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matter-in-motion","download_url":"https://codeload.github.com/matter-in-motion/mm-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239665969,"owners_count":19677059,"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","extension","formdata","matter-in-motion","processor","resources"],"created_at":"2024-12-29T06:19:52.610Z","updated_at":"2025-12-08T12:30:13.666Z","avatar_url":"https://github.com/matter-in-motion.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matter In Motion. File uploads and processing resource extension\n\n[![NPM Version](https://img.shields.io/npm/v/mm-file.svg?style=flat-square)](https://www.npmjs.com/package/mm-file)\n[![NPM Downloads](https://img.shields.io/npm/dt/mm-file.svg?style=flat-square)](https://www.npmjs.com/package/mm-file)\n\nThis extension adds a __file__ resource.\n\n## Usage\n\n[Extensions installation instructions](https://github.com/matter-in-motion/mm/blob/master/docs/extensions.md).\n\nThis extension validates file type **before** downloading file.\n\n## File upload\n\nYou can upload files via [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData).\n\n## Settings\n\n* defaults — object, any default options. Will be applied to the jobs.\n* **jobname** — object, job declaration\n  - to — string, default filename. Will be applied if action options doesn't have the `to` option\n  - limit — number, maximum files to be accepted\n  - **accept** — array, list of the mime types accepted by this job\n  - **do** — array, list of action to be applied to each file\n    + `{ 'processor:action': {options}}` — action with its options.\n\nSettings example:\n\n```js\nthis.file = {\n  defaults: {\n    root: this.join('static', 'uploads') // files storage root.\n  },\n\n  test: {\n    accept: [ 'image/jpeg' ],\n    do: [\n      { 'fs:copy': { name: 'copy', to: '{filename}_{copy}{_#}{ext}' } }\n    ]\n  }\n};\n```\n\n### Processor action options\n\nAll actions have only two common options: `name` and `to`.\n\n### Path patterns\n\nThe following curly bracket variables can be used in the `to` option:\n\n* fieldname — field name from form data\n* filename — original file name\n* ext — original file extension\n* name — action name\n* year — four digits year\n* month —  the padded _(ex. 01)_ number, 1-based\n* day —  the padded number, 1-based\n* \\# — unique file pattern [read more about it here](https://github.com/velocityzen/fsu)\n\nplus any data that particular processor accepts with the files.\n\n## Safe\n\nAll generated file paths and names are sanitized. You can upload files with names in any encoding supported by JavaScript.\n\n## File processors\n\n* __fs__ — built-in processor with the following methods:\n  - __copy__ copies file\n  - __move__ moves file\n  - __delete__ deletes file\n* __[image](https://github.com/matter-in-motion/mm-file-image)__ — super fast image processor __with animated GIF support__\n\nFor processors methods and options go to processors docs.\n\n## API\n\n### process\n\nProcesses the file or files with the job\n\n**Request**\n\nAll files and any other data should be sent as [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData).\n\n* **job** — job name to use for files\n\n**Respond**\n\nDepends on the processors used in the job.\n\nLicense: MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatter-in-motion%2Fmm-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatter-in-motion%2Fmm-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatter-in-motion%2Fmm-file/lists"}