This project provides a RESTful API for uploading files securely. The files are encrypted before being saved to the database, ensuring that sensitive information is protected. The API allows users to upload single or multiple files, retrieve files by email, and rename files as needed.
- Creation of user.
- Log in
- Upload a single file with encryption.
- Upload multiple files with encryption.
- Retrieve decrypted files using the JWT token files by user email.
- Rename existing files.
- Java
- Spring Boot
- JPA (Java Persistence API)
- Hibernate
- MultipartFile for file uploads
| Attribute | Type | Column Name | Description |
|---|---|---|---|
id |
Long |
id |
Primary key; auto-generated ID |
fileName |
String |
file_name |
Name of the file |
fileData |
byte[] |
file_data |
Binary data of the file, stored as LONGBLOB |
email |
String |
email |
Email associated with the file |
Here's an updated README to reflect that the User class implements UserDetails:
| Attribute | Type | Column Name | Description |
|---|---|---|---|
id |
Long |
id |
Primary key; identity generation strategy |
email |
String |
email |
User's email, must not be null |
password |
String |
password |
User's password, must not be null |
- Implements:
UserDetails— Allows integration with Spring Security, making theUserclass suitable for user authentication and authorization.
- Endpoint:
/api/v1/user/create
Request Body
{
"email": "[email protected]",
"password": "userPassword"
}Response:
{
"status": 200,
"message": "user created",
"data": "[email protected]"
}- Endpoint:
/api/v1/auth/login
Request Body
{
"email": "[email protected]",
"password": "userPassword"
}Response:
{
"status": 200,
"message": "logged in successfully",
"data": TOKEN
}Endpoint: POST /api/v1/file/upload
Request Body:
file: MultipartFile (the file to upload)
Response:
{
"status": 200,
"message": "file saved",
"data": "original_filename.enc"
}Endpoint: POST /api/v1/file/upload-multiple
Request Body:
email: String (user's email)
files: List<MultipartFile> (the files to upload)
Response:
{
"status": 200,
"message": "Files saved successfully",
"data": ["original_filename1.enc", "original_filename2.enc"]
}Endpoint: GET /api/v1/file/user-files
Request Parameters:
email: String (user's email)
Response:
{
"status": 200,
"message": "Filenames retrieved successfully.",
"data": ["file1.enc", "file2.enc"]
}Endpoint: PUT /api/v1/file/update-fileName/{id}
Request Body:
fileName: String (new name for the file)
Response:
{
"status": 200,
"message": "File name Updated!!!"
}Files uploaded through this API are encrypted using a custom encryption method. The encryption logic is applied to the file's input stream before saving it to the database, ensuring that the file contents remain confidential.
-
Clone the repository:
git clone <repository-url>
-
Navigate to the project directory:
cd <project-directory>
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
The API will be available at
http://localhost:1001/api/v1.