{"id":19776660,"url":"https://github.com/andresp08/springboot-file-upload","last_synced_at":"2025-06-30T20:06:12.545Z","repository":{"id":207023240,"uuid":"718230160","full_name":"Andresp08/springBoot-file-upload","owner":"Andresp08","description":"This Spring Boot application is designed to facilitate generic CSV file uploads with a focus on flexibility and ease of use. The primary goal of this project is to allow users to upload CSV files.","archived":false,"fork":false,"pushed_at":"2023-11-13T18:46:26.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T12:07:40.715Z","etag":null,"topics":["file-upload","java","maven","opencsv","postgresql","springboot","swagger-ui"],"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/Andresp08.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":"2023-11-13T16:48:02.000Z","updated_at":"2023-11-13T18:48:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"52f4b0c5-c5fb-415a-81af-99a6619e4a46","html_url":"https://github.com/Andresp08/springBoot-file-upload","commit_stats":null,"previous_names":["andresp08/springboot-file-upload"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Andresp08/springBoot-file-upload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andresp08%2FspringBoot-file-upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andresp08%2FspringBoot-file-upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andresp08%2FspringBoot-file-upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andresp08%2FspringBoot-file-upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Andresp08","download_url":"https://codeload.github.com/Andresp08/springBoot-file-upload/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andresp08%2FspringBoot-file-upload/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262842924,"owners_count":23373167,"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":["file-upload","java","maven","opencsv","postgresql","springboot","swagger-ui"],"created_at":"2024-11-12T05:21:03.395Z","updated_at":"2025-06-30T20:06:12.479Z","avatar_url":"https://github.com/Andresp08.png","language":"Java","readme":"# SpringBoot File Upload\n\n`Swagger Documentation`\n\n![file upload success](https://github.com/Andresp08/springBoot-file-upload/assets/45151760/f1ecd288-3b75-4f25-8a31-0e0ccb470d84)\n\n## Upload files with springboot using opencsv\n\n## If you want to use this generic file upload without the anotation @CsvBindByName, you can replace the GenericCsvParseToEntity methods for:\n\n    public Set\u003cEntity\u003e parseCsvToEntity(MultipartFile file, Class\u003cEntity\u003e entityClass) throws IOException,  \n    CsvValidationException {  \n\t    Set\u003cEntity\u003e entities = new HashSet\u003c\u003e();  \n      \n\t\t    try (CSVReader reader = new CSVReader(new InputStreamReader(file.getInputStream()))) {  \n\t\t\t    String[] header = reader.readNext();  \n\t\t\t    String[] line;  \n\t\t\t      \n\t\t\t    while ((line = reader.readNext()) != null) {  \n\t\t\t    Entity entity = buildEntity(header, line, entityClass);  \n\t\t\t    entities.add(entity);  \n\t\t    }  \n\t    }    \n\t    return entities;  \n    }  \n      \n    private Entity buildEntity(String[] header, String[] line, Class\u003cEntity\u003e entityClass) {  \n\t    try {  \n\t\t    Entity entity = entityClass.getDeclaredConstructor().newInstance();  \n\t\t      \n\t\t    for (int i = 0; i \u003c header.length; i++) {  \n\t\t    String columnName = header[i];  \n\t\t    String cellValue = line[i];  \n\t\t      \n\t\t    Field field = entityClass.getDeclaredField(columnName);  \n\t\t    field.setAccessible(true);  \n\t\t      \n\t\t    if (field.getType() == String.class) {  \n\t\t\t    field.set(entity, cellValue);  \n\t\t    } else if (field.getType() == int.class) {  \n\t\t\t    field.set(entity, Integer.parseInt(cellValue));  \n\t\t    }    \n\t\t    field.setAccessible(false);  \n\t    }  \n\t    return entity;  \n\t    } catch (Exception e) {  \n\t\t    throw new RuntimeException(\"Error al construir entidad\", e);  \n\t    }  \n\t }\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandresp08%2Fspringboot-file-upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandresp08%2Fspringboot-file-upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandresp08%2Fspringboot-file-upload/lists"}