{"id":25425017,"url":"https://github.com/edgar-code-repository/spring-boot-upload-demo","last_synced_at":"2025-07-16T15:34:04.111Z","repository":{"id":277041778,"uuid":"930050231","full_name":"edgar-code-repository/spring-boot-upload-demo","owner":"edgar-code-repository","description":"A JSON file is received and processed in a Rest API.","archived":false,"fork":false,"pushed_at":"2025-02-17T00:08:06.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T02:14:42.769Z","etag":null,"topics":["backend","java17","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","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/edgar-code-repository.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":"2025-02-10T01:16:15.000Z","updated_at":"2025-02-17T00:08:09.000Z","dependencies_parsed_at":"2025-02-11T20:44:07.509Z","dependency_job_id":null,"html_url":"https://github.com/edgar-code-repository/spring-boot-upload-demo","commit_stats":null,"previous_names":["edgar-code-repository/spring-boot-upload-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/edgar-code-repository/spring-boot-upload-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgar-code-repository%2Fspring-boot-upload-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgar-code-repository%2Fspring-boot-upload-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgar-code-repository%2Fspring-boot-upload-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgar-code-repository%2Fspring-boot-upload-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edgar-code-repository","download_url":"https://codeload.github.com/edgar-code-repository/spring-boot-upload-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edgar-code-repository%2Fspring-boot-upload-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265521542,"owners_count":23781529,"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":["backend","java17","spring-boot"],"created_at":"2025-02-16T23:18:59.980Z","updated_at":"2025-07-16T15:34:04.090Z","avatar_url":"https://github.com/edgar-code-repository.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"UPLOAD DEMO\n-----------------------------------------------------------------------------------------------------\n\n**A JSON file is received and processed in a Rest API.**\n\n![java+json](images/json+java.png)\n\n**Each row in the file is stored in Azure SQL.**\n\n![azuresql](images/azure-sql.png)\n\n-----------------------------------------------------------------------------------------------------\n\n**The file contains this data:**\n\n```\n\n[\n  { \"id\": 1, \"name\": \"Alice\", \"email\": \"alice@example.com\" },\n  { \"id\": 2, \"name\": \"Bob\", \"email\": \"bob@example.com\" },\n  { \"id\": 3, \"name\": \"Charlie\", \"email\": \"charlie@example.com\" },\n  ...\n  ...\n  ...\n]\n\n```\n\n-----------------------------------------------------------------------------------------------------\n\n**Endpoint that receives the file:**\n\n```\n    @PostMapping\n    public ResponseEntity\u003cResponseUploadDTO\u003e uploadFile(@RequestParam(\"file\") MultipartFile file) {\n        log.debug(\"[uploadFile][BEGIN]\");\n        ResponseUploadDTO responseUploadDTO = fileUploadService.uploadClientsFile(file);\n        log.debug(\"[uploadFile][END]\");\n        return ResponseEntity.ok(responseUploadDTO);\n    }\n```\n\n-----------------------------------------------------------------------------------------------------\n\n**Method that handles the JSON file:**\n\n```\n    @Override\n    public ResponseUploadDTO uploadClientsFile(MultipartFile file) {\n        log.debug(\"[uploadClientsFile][BEGIN]\");\n\n        ResponseUploadDTO responseDTO = ResponseUploadDTO.builder().build();\n        try {\n            List\u003cClientDTO\u003e clients = objectMapper.readValue(file.getInputStream(), new TypeReference\u003cList\u003cClientDTO\u003e\u003e() {});\n            clients.forEach(client -\u003e log.debug(\"[uploadClientsFile][client: {}]\", client));\n            responseDTO.setCode(101);\n            responseDTO.setMessage(\"File uploaded successfully: \" + file.getOriginalFilename());\n        } catch (Exception e) {\n            responseDTO.setCode(102);\n            responseDTO.setMessage(\"Failed to upload file: \" + e.getMessage());\n            log.error(\"[uploadClientsFile][error: {}]\", e.toString());\n        }\n\n        log.debug(\"[uploadClientsFile][END]\");\n        return responseDTO;\n    }\n```\n\n-----------------------------------------------------------------------------------------------------\n\n**The endpoint is executed using Postman:**\n\n![postman](screenshots/postman.png)\n\n-----------------------------------------------------------------------------------------------------","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgar-code-repository%2Fspring-boot-upload-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedgar-code-repository%2Fspring-boot-upload-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgar-code-repository%2Fspring-boot-upload-demo/lists"}