https://github.com/johnufo/app-file-upload-download
This project is a Spring Boot-based application for uploading and downloading files. It supports storing files in both a database (PostgreSQL) and the local file system.
https://github.com/johnufo/app-file-upload-download
jpa multipart-file postgresql spring
Last synced: 3 months ago
JSON representation
This project is a Spring Boot-based application for uploading and downloading files. It supports storing files in both a database (PostgreSQL) and the local file system.
- Host: GitHub
- URL: https://github.com/johnufo/app-file-upload-download
- Owner: JohnUfo
- Created: 2024-09-19T11:34:17.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-03-04T14:49:02.000Z (3 months ago)
- Last Synced: 2025-03-04T15:36:06.093Z (3 months ago)
- Topics: jpa, multipart-file, postgresql, spring
- Language: Java
- Homepage:
- Size: 225 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# File Upload and Download Application
This project is a Spring Boot-based application for uploading and downloading files. It supports storing files in both a database (PostgreSQL) and the local file system.
## Features
- Upload files to a database
- Upload files to the system (local storage)
- Retrieve files from the database
- Retrieve files from the system## Technologies Used
- **Spring Boot**
- **Spring Data JPA**
- **PostgreSQL**
- **Jakarta Persistence (JPA)**
- **Multipart File Handling**## Project Structure
```
app-file-upload-download/
├── src/main/java/uz/muydinovs/appfileuploaddownload
│ ├── controller/
│ │ ├── AttachmentController.java
│ ├── entity/
│ │ ├── Attachment.java
│ │ ├── AttachmentContent.java
│ ├── repository/
│ │ ├── AttachmentRepository.java
│ │ ├── AttachmentContentRepository.java
├── src/main/resources/
│ ├── application.properties
```## Installation & Setup
### Prerequisites
- **Java 17+**
- **PostgreSQL**
- **Maven**### Steps
1. Clone the repository:
```sh
git clone https://github.com/JohnUfo/app-file-upload-download.git
cd app-file-upload-download
```2. Configure PostgreSQL Database:
- Update `application.properties` with your PostgreSQL credentials:
```properties
spring.datasource.url=jdbc:postgresql://localhost:5432/app_file
spring.datasource.username=postgres
spring.datasource.password=2373
spring.jpa.hibernate.ddl-auto=update
```3. Build and Run the Application:
```sh
mvn spring-boot:run
```## API Endpoints
### Upload File
#### To Database:
```http
POST /attachment/uploadDb
```
- **Request:** Multipart File
- **Response:** `Successfully saved! ID: {id}`#### To System:
```http
POST /attachment/uploadSystem
```
- **Request:** Multipart File
- **Response:** `Successfully saved! ID: {id}`### Retrieve File
#### From Database:
```http
GET /attachment/getFileFromDb/{id}
```
- **Response:** File as a downloadable attachment#### From System:
```http
GET /attachment/getFileFromSystem/{id}
```
- **Response:** File as a downloadable attachment## Notes
- The uploaded files in the system are saved in the `downloads` folder.
- Ensure PostgreSQL is running before starting the application.