This is an APIs that allows you to upload user files to Four types of file storage S3, DB, Local, or FTP.
Before you begin, ensure you have met the following requirements as I have it:
- You have installed Ruby version ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x64-mingw-ucrt]
- You have installed Rails version 7.1.3.2
- You have installed node v20.12.0
These instructions will get you a copy of the project up and running on your local machine for development and testing.
To clone the repository, run the following command:
git clone https://github.com/AamerHejazi/simple_storage_api.gitRun the database migrations:
rails db:migratePopulate the database by running the following:
rails db:seedTo start the Rails server, run:
rails servernow the base path of the server is http://localhost:3000
You can find it inside the root folder with the file name erd.pdf
POST '/register'Before you start using the APIs you need to create an account using this API with the following:
You need to send the below fields:
{
"email": "admin5@example.com",
"password": "admin5",
"password_confirmation": "admin5"
}This API will return the ID and the email in the response with HTTP code created 201 with the following response
{
"id": "5",
"email": "admin5@example.com"
}POST '/login'to start using the APIs you need to create a token using this API with the following:
You need to send the below fields:
{
"email": "admin5@example.com",
"password": "admin5"
}This API will return the id and the email in the response with HTTP code OK 200
with the following response
{
"bearer_token": "92ba8fabbc23060e65ed3ad9089e02242be43643",
"expires_at": "2024-05-11T05:02:56.214Z"
}Now you can use the token in the headers Authorization to call other APIs and set the value is 92ba8fabbc23060e65ed3ad9089e02242be43643
POST '/v1/blobs'
{
"id": "blob_id",
"data": "base64 data"
}This API will return the id,data,size, and created_at in the response with HTTP code Created 201 with the following response
{
"id": "blob_id",
"data": "base64 data",
"size": 300,
"created_at": "2024-04-13T15:19:52.621Z"
}GET '/v1/blobs/{blobId}'
This API will return the id,data,size, and created_at in the response with HTTP code OK 200 with the following response
{
"id": "blob_id",
"data": "base64 data",
"size": 300,
"created_at": "2024-04-13T15:19:52.621Z"
}To run all test cases for the application use the below command
rspec spec- Before Running the Application you need to create a
.envfile inside therootrepository and configure the following key and secret related to the S3 server:
MINIO_ACCESS_KEY=YOURKEY
MINIO_SECRET_KEY=YOURSECRET-
By default the app will store the data inside S3 and to change it for Local storage on your machine or DB change the value inside this file
config/initializers/select_storage_service.rbAvailable values areDB,Local,S3,FTP -
"
FTP Not Implemented Yet"