{"id":18822224,"url":"https://github.com/rupomsoft/express-fileforge","last_synced_at":"2025-04-14T01:07:56.641Z","repository":{"id":220083031,"uuid":"750711827","full_name":"rupomsoft/express-fileforge","owner":"rupomsoft","description":"express-fileforge is a file upload utility for Express.js that simplifies file handling. It provides a convenient way to save files to the server and manage file storage paths. This package is designed to be easy to use and integrate seamlessly with your Express.js applications.","archived":false,"fork":false,"pushed_at":"2024-02-06T08:02:31.000Z","size":195,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T01:07:45.931Z","etag":null,"topics":[],"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/rupomsoft.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-31T06:57:21.000Z","updated_at":"2025-02-22T10:40:04.000Z","dependencies_parsed_at":"2024-02-06T08:35:17.976Z","dependency_job_id":null,"html_url":"https://github.com/rupomsoft/express-fileforge","commit_stats":null,"previous_names":["rupomsoft/express-fileforge"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupomsoft%2Fexpress-fileforge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupomsoft%2Fexpress-fileforge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupomsoft%2Fexpress-fileforge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rupomsoft%2Fexpress-fileforge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rupomsoft","download_url":"https://codeload.github.com/rupomsoft/express-fileforge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804803,"owners_count":21164134,"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":[],"created_at":"2024-11-08T00:48:29.450Z","updated_at":"2025-04-14T01:07:56.611Z","avatar_url":"https://github.com/rupomsoft.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"`express-fileforge` is a file upload utility for Express.js that simplifies file handling. It provides a convenient way to save files to the server and manage file storage paths. This package is designed to be easy to use and integrate seamlessly with your Express.js applications.\n\n```bash\nnpm install express-fileforge\n```\n\n## Express JS Example \n```javascript\nconst express = require('express');\nconst fileForge = require('express-fileforge'); \nconst path = require('path');\nconst app = express();\n\n// Your route for file upload\napp.post('/upload', async function (req, res) {\n    try {\n        // Upload file\n        let uploadedFile = await fileForge.saveFile(req, path.resolve(__dirname),'myFiles', 'abc.pdf');\n        res.end(`File uploaded successfully: ${uploadedFile}`);\n    } catch (error) {\n        console.error(error);\n        res.status(500).end('Internal Server Error');\n    }\n});\n\n// Route for file deletion\napp.delete('/delete/:fileName', async function (req, res) {\n    try {\n\n        // File name from the URL parameter\n        const fileName = req.params.fileName;\n\n        // Delete the specified file\n        const isDeleted = await fileForge.deleteFile(path.resolve(__dirname),'myFiles',  fileName);\n        if (isDeleted) {\n            res.end(`File deleted successfully: ${fileName}`);\n        } else {\n            res.status(404).end(`File not found: ${fileName}`);\n        }\n    } catch (error) {\n        console.error(error);\n        res.status(500).end('Internal Server Error');\n    }\n});\n\n// Start the server\napp.listen(5050, function () {\n    console.log('Server Run Success');\n});\n\n```\n\n\n## How To Upload Using Fetch \n```javascript\nasync function uploadFile() {\n  try {\n    var formdata = new FormData();\n    formdata.append(\"files\", fileInput.files[0]);\n\n    var requestOptions = {\n      method: 'POST',\n      body: formdata,\n      redirect: 'follow',\n    };\n\n    const response = await fetch(\"http://localhost:5050/uploads\", requestOptions);\n    const result = await response.text();\n    console.log(result);\n  } catch (error) {\n    console.log('error', error);\n  }\n}\n\n// Call the function\nuploadFile();\n\n```\n\n\n\n## How To Upload Using Axios\n```javascript\nasync function uploadFile() {\n    try {\n        const formData = new FormData();\n        formData.append(\"files\", fileInput.files[0]);\n\n        const response = await axios.post(\"http://localhost:5050/uploads\", formData, {\n            headers: {\n                'Content-Type': 'multipart/form-data',\n            },\n        });\n\n        console.log(response.data);\n    } catch (error) {\n        console.error('Error:', error);\n    }\n}\n\n// Call the function\nuploadFile();\n\n```\n\n\n\n## How To Delete Using Fetch\n```javascript\nconst deleteFile = async () =\u003e {\n    const FileName = \"abc.pdf\";\n    const requestOptions = {method: 'DELETE'};\n    try {\n        const response = await fetch(`http://localhost:5050/delete/${FileName}`, requestOptions);\n        if (!response.ok) {\n            throw new Error(`HTTP error! Status: ${response.status}`);\n        }\n        const result = await response.text();\n        console.log(result);\n    } catch (error) {\n        console.log('error', error);\n    }\n};\n// Call the async function\ndeleteFile();\n\n```\n\n\n\n## How To Delete Using Axios\n```javascript\nconst deleteFile = async () =\u003e {\n    const FileName = \"abc.pdf\";\n    try {\n        const response = await axios.delete(`http://localhost:5050/delete/${FileName}`);\n        console.log(response.data);\n    } catch (error) {\n        console.log('error', error.message);\n    }\n};\n// Call the async function\ndeleteFile();\n```\n\n\n\n## License\n\nThis package is licensed under the MIT License - see the LICENSE file for details.\n\n## Acknowledgments\n- This package is inspired by the need for a simple and efficient file upload solution for Express.js applications.\n- Thanks to the Express.js and Node.js communities for their valuable contributions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupomsoft%2Fexpress-fileforge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frupomsoft%2Fexpress-fileforge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frupomsoft%2Fexpress-fileforge/lists"}