{"id":14957387,"url":"https://github.com/rupomsoft/next-file","last_synced_at":"2025-10-01T16:31:51.250Z","repository":{"id":224868404,"uuid":"764448184","full_name":"rupomsoft/Next-File","owner":"rupomsoft","description":"Next-File is a lightweight npm package tailored for file management within Next.js applications. It simplifies the process of uploading files to your Next.js server and provides an easy-to-use interface for deleting files when they are no longer needed. With seamless integration into Next.js projects, this package offers robust functionality to han","archived":false,"fork":false,"pushed_at":"2024-02-29T09:02:39.000Z","size":445,"stargazers_count":33,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-18T05:12:13.237Z","etag":null,"topics":["next","next-js","nextjs"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rupomsoft.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-28T04:59:46.000Z","updated_at":"2024-12-25T11:55:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"88de23bd-d6b7-4389-8131-d1b416f5a43e","html_url":"https://github.com/rupomsoft/Next-File","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"7b20f0493328fb8924f71a1c974eda3d59694438"},"previous_names":["rupomsoft/next-file"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupomsoft%2FNext-File","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupomsoft%2FNext-File/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupomsoft%2FNext-File/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupomsoft%2FNext-File/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rupomsoft","download_url":"https://codeload.github.com/rupomsoft/Next-File/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234883315,"owners_count":18901365,"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":["next","next-js","nextjs"],"created_at":"2024-09-24T13:14:49.751Z","updated_at":"2025-10-01T16:31:45.953Z","avatar_url":"https://github.com/rupomsoft.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"Next-File is a lightweight npm package tailored for file management within Next.js applications. It simplifies the process of uploading files to your Next.js server and provides an easy-to-use interface for deleting files when they are no longer needed. With seamless integration into Next.js projects, this package offers robust functionality to handle file uploads and deletions efficiently, enhancing the development experience for Next.js developers.\n\n#### Install Using NPM\n```javascript\nnpm i next-file\n```\n#### Install Using Yarn\n```javascript\nyarn add next-file\n```\n\n\n![next-file.png](next-file.jpg)\nFeatures:\n- File Upload: Easily upload files to your Next.js server with minimal configuration.\n- File Deletion: Delete files from your server effortlessly when they are no longer required.\n- Supported Formats: Supports a wide range of file formats including images, documents, and more.\n- Error Handling: Provides comprehensive error handling to ensure smooth file management operations.\n- Lightweight: Designed to be lightweight and unobtrusive, minimizing overhead and optimizing performance.\n- Next.js Integration: Seamlessly integrates into Next.js projects, maintaining compatibility with the Next.js ecosystem.\n\n\n#### Example File Upload Form Next.js Route \n```javascript\nexport async function POST(req,res) {\n    try{\n        let result=await Upload(req,\"files\",['jpg','png','pdf'])\n        return NextResponse.json({status:\"success\",data:result})\n    }\n    catch (e) {\n        return  NextResponse.json({status:\"fail\",data:e})\n    }\n}\n```\n\n#### Example File Delete Form Next.js Route\n```javascript\nexport async function DELETE(req,res) {\n    try{\n        const filePath = './public/files/1709098593107_demo.png';\n        let result=await deleteFile(filePath)\n        return NextResponse.json({status:\"success\",data:result})\n    }\n    catch (e) {\n        return  NextResponse.json({status:\"fail\",data:e})\n    }\n}\n```\n\n#### Example Multipart Form Data Request Using Axios From React Component\n\n```javascript\nimport React, { useState } from 'react';\nimport axios from 'axios';\n\nconst FileUploadForm = () =\u003e {\n  const [selectedFile, setSelectedFile] = useState(null);\n\n  const handleFileChange = (event) =\u003e {\n    setSelectedFile(event.target.files[0]);\n  };\n\n  const handleSubmit = async (event) =\u003e {\n    event.preventDefault();\n\n    if (!selectedFile) {\n      alert('Please select a file');\n      return;\n    }\n\n    try {\n      const formData = new FormData();\n      formData.append('file', selectedFile);\n\n      const response = await axios.post('http://localhost:3000/api/upload', formData, {\n        headers: {\n          'Content-Type': 'multipart/form-data'\n        }\n      });\n\n      console.log('File uploaded successfully:', response.data);\n    } catch (error) {\n      console.error('Error uploading file:', error);\n    }\n  };\n\n  return (\n    \u003cdiv\u003e\n      \u003ch2\u003eFile Upload\u003c/h2\u003e\n      \u003cform onSubmit={handleSubmit}\u003e\n        \u003cinput type=\"file\" onChange={handleFileChange} /\u003e\n        \u003cbutton type=\"submit\"\u003eUpload\u003c/button\u003e\n      \u003c/form\u003e\n    \u003c/div\u003e\n  );\n};\n\nexport default FileUploadForm;\n\n```\n#### Example Multipart Form Data Request Using Fetch API From React Component\n\n```javascript\nimport React, { useState } from 'react';\n\nconst FileUploadForm = () =\u003e {\n  const [selectedFile, setSelectedFile] = useState(null);\n\n  const handleFileChange = (event) =\u003e {\n    setSelectedFile(event.target.files[0]);\n  };\n\n  const handleSubmit = async (event) =\u003e {\n    event.preventDefault();\n\n    if (!selectedFile) {\n      alert('Please select a file');\n      return;\n    }\n\n    try {\n      const formData = new FormData();\n      formData.append('file', selectedFile);\n\n      const response = await fetch('http://localhost:3000/api/upload', {\n        method: 'POST',\n        body: formData\n      });\n\n      if (!response.ok) {\n        throw new Error(`HTTP error! status: ${response.status}`);\n      }\n\n      const data = await response.json();\n      console.log('File uploaded successfully:', data);\n    } catch (error) {\n      console.error('Error uploading file:', error);\n    }\n  };\n\n  return (\n    \u003cdiv\u003e\n      \u003ch2\u003eFile Upload\u003c/h2\u003e\n      \u003cform onSubmit={handleSubmit}\u003e\n        \u003cinput type=\"file\" onChange={handleFileChange} /\u003e\n        \u003cbutton type=\"submit\"\u003eUpload\u003c/button\u003e\n      \u003c/form\u003e\n    \u003c/div\u003e\n  );\n};\n\nexport default FileUploadForm;\n\n```\n\n\nMIT License\n\nCopyright (c) [2024] [RABBIL HASAN]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupomsoft%2Fnext-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frupomsoft%2Fnext-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupomsoft%2Fnext-file/lists"}