This application allows users to upload files, storing and encrypting them for security. Users can download the archived files and decrypt them using the password provided during the upload process.
-
Ruby version: 3.1.4
-
MySQL Database Configuration:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost'; FLUSH PRIVILEGES;
-
Project Setup:
bundle install rails db:setup
Start the server and navigate to /api/docs
for the API documentation.
Authenticate a user by sending a GET /api/login
request with the following body:
{
"user": {
"email": "[email protected]",
"password": "password"
}
}
The response will include a JWT, which is required for the Auth Bearer token when uploading or reading files.
To upload and encrypt a file, send a POST /api/files
request with the file attachment as a MultiPart form. The response will include a message, the URL of the uploaded file, and a password for decryption:
{
"message": "File 'foo.png' uploaded and archived with password successfully.",
"url": "http://localhost:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTEsInB1ciI6ImJsb2JfaWQifX0=--18da61b9f3847d27f5c19807308d66b2c69bac05/foo.png.zip",
"password": "25e008b2"
}
To retrieve all attached files, send a GET /api/files
request. The response will return a list of attached files:
[
{
"filename": "foo.png.zip",
"url": "http://localhost:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MSwicHVyIjoiYmxvYl9pZCJ9fQ==--189d9bfdc057c1f47a803fefc1ff8efb6e65c573/foo.png.zip"
}
]
rspec