{"_id":"@admandev/multer-ftp-storage","name":"@admandev/multer-ftp-storage","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@admandev/multer-ftp-storage","version":"1.0.0","description":"Multer storage engine for FTP","license":"MIT","author":{"name":"Admandev"},"typesVersions":{"*":{"*":["./*"]}},"exports":{".":{"import":"./index.mjs","require":"./index.js","types":"./index.d.ts"}},"main":"./index.js","module":"./index.mjs","typings":"./index.d.ts","repository":{"type":"git","url":""},"keywords":["multer","ftp","storage","server","engine"],"dependencies":{"basic-ftp":"^5.0.5"},"peerDependencies":{"multer":"^1.4.5-lts.1"},"_id":"@admandev/multer-ftp-storage@1.0.0","gitHead":"2ce35b87c2a4423bcfc68a2a64e7655ddcf69c72","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-i4FWdDueXgGcfc9d899/IgUddPiOLrehTznFsWGrwVUzFupYd1zExfLS2otqa9prGlIc3keiiitl8ban+rKMrw==","shasum":"a90b85de93cac8d3821e5fe723ab06670af8e9e6","tarball":"https://registry.npmjs.org/@admandev/multer-ftp-storage/-/multer-ftp-storage-1.0.0.tgz","fileCount":7,"unpackedSize":18859,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCbKTCJrXhpeSdVDGNd5MCrY072lf3sy1MXXrmigCaZCQIgcm4kSFCn/c1GVfFIM1GzIjjj6fsqTaVWOF67JAn1Vj4="}]},"_npmUser":{"name":"admandev","email":"adman.software@gmail.com"},"directories":{},"maintainers":[{"name":"admandev","email":"adman.software@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multer-ftp-storage_1.0.0_1726999252142_0.7549021885883567"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-22T10:00:52.014Z","1.0.0":"2024-09-22T10:00:52.311Z","modified":"2024-09-22T10:00:52.598Z"},"maintainers":[{"name":"admandev","email":"adman.software@gmail.com"}],"description":"Multer storage engine for FTP","keywords":["multer","ftp","storage","server","engine"],"repository":{"type":"git","url":""},"author":{"name":"Admandev"},"license":"MIT","readme":"# Multer-ftp-storage\r\n\r\nThis is a custom storage engine for [Multer](https://github.com/expressjs/multer) that allows you to upload files via FTP. This package integrates Multer's file handling with the simplicity of FTP, making it easy to store files on a remote server.\r\n\r\n## Installation\r\n\r\nInstall the package via npm:\r\n\r\n```bash\r\nnpm install @admandev/multer-ftp-storage multer\r\n```\r\n\r\n## Usage\r\n\r\nBelow is an example of how to configure and use it\r\n\r\n```javascript\r\nimport express from \"express\";\r\nimport { Router } from \"express\";\r\nimport multer from \"multer\";\r\nimport MulterFtpStorage from \"@admandev/multer-ftp-storage\";\r\nimport Controller from \"./controller\";\r\n\r\n// Create an FTP storage engine\r\nconst ftpStorage = new MulterFtpStorage({\r\n  ftp: {\r\n    host: \"Your FTP host\", \r\n    user: \"Your FTP user\", \r\n    password: \"Your FTP user password\", \r\n    basepath: \"Your FTP base file folder\" // Without slash at the end\r\n  },\r\n});\r\n\r\n// Initialize multer with the FTP storage engine\r\nconst multerConfig = multer({ storage: ftpStorage });\r\n\r\nconst app = express();\r\nconst router = Router();\r\n\r\n// Define a POST route to upload files\r\nrouter.post(\"/\", multerConfig.any(), Controller.postFile);\r\n\r\napp.use(\"/upload\", router);\r\n\r\napp.listen(3000, () => {\r\n  console.log(\"Server started on http://localhost:3000\");\r\n});\r\n\r\n```\r\n\r\n## Options\r\n\r\nThe `MulterFtpStorage` constructor accepts an options object with the following properties:\r\n\r\n- `ftp`: An object with the following properties:\r\n  - `host`: The FTP host to connect to.\r\n  - `user`: The FTP user to authenticate with.\r\n  - `password`: The password for the FTP user.\r\n  - `basepath`: The base folder on the FTP server where files will be stored. This is optional and defaults to the root folder.\r\n- `multer`: An object with the following properties:\r\n  - `fileNameFn`: A function that generates the file name for the uploaded file. This function receives the request object and the file object as arguments and should return a string with the file name. This is optional and defaults to a function that generates a random file name.\r\n","readmeFilename":"README.md"}