This is a File Management API Server providing a REST API with uploading feature and their removals. And which are accessible over public internet.
The Application is hosted at : https://global-file-upload.herokuapp.com/
npm install
npm start
The REST API to the example app is described below.
POST /signup
curl --location --request POST 'https://global-file-upload.herokuapp.com/signup' \
--header 'Content-Type: application/json' \
--data-raw '{
"username":"rohan kumar jain",
"email":"rohan@gmail.com",
"password":"abc",
"confpassword":"abc"
}'
Status: 201 CREATED
Content-Type: application/json
{"msg": "User created Successfully"}
GET /login
curl --location --request GET 'https://global-file-upload.herokuapp.com/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"email":"rohan@gmail.com",
"password":"abc"
}'
Status: 200 OK
Content-Type: application/json
{"token":"abc"}
GET /file
curl --location --request GET 'https://global-file-upload.herokuapp.com/file' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDI5NGY1MzQ2NmY2NjAwMjJjODFmNGEiLCJ1c2VybmFtZSI6InJvaGFuIGt1bWFyIGphaW4iLCJlbWFpbCI6InJvaGFuQGdtYWlsLmNvbSIsImlhdCI6MTYxMzMyMDE4MiwiZXhwIjoxNjEzMzM4MTgyfQ.6ZlPsT4UeVD-RJNRNYDIuI4s58rJLdCfR04s_V5RzF4'
In curl, provide valid token for proper execution
Status: 200 OK
Content-Type: application/json
{
"msg": [
{
"_id": "6029505c466f660022c81f4b",
"user_id": "60294f53466f660022c81f4a",
"file_name": "IMG_b8d9rd.jpg",
"link": "https://freebucket.s3.amazonaws.com/IMG_b8d9rd.jpg",
"__v": 0
}
]
}
POST /upload-file
curl --location --request POST 'https://global-file-upload.herokuapp.com/upload-file' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDI5NGY1MzQ2NmY2NjAwMjJjODFmNGEiLCJ1c2VybmFtZSI6InJvaGFuIGt1bWFyIGphaW4iLCJlbWFpbCI6InJvaGFuQGdtYWlsLmNvbSIsImlhdCI6MTYxMzMyMDE4MiwiZXhwIjoxNjEzMzM4MTgyfQ.6ZlPsT4UeVD-RJNRNYDIuI4s58rJLdCfR04s_V5RzF4' \
--form 'file=@"/home/rohan_kumar_jain/Downloads/IMG_b8d9rd.jpg"'
In curl, provide valid token and file for proper execution.
Status: 200 OK
Content-Type: application/json
{
"msg": {
"_id": "6029505c466f660022c81f4b",
"user_id": "60294f53466f660022c81f4a",
"file_name": "IMG_b8d9rd.jpg",
"link": "https://freebucket.s3.amazonaws.com/IMG_b8d9rd.jpg",
"__v": 0
}
}
DELETE /delete-file
curl --location --request DELETE 'https://global-file-upload.herokuapp.com/delete-file' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDI5NGY1MzQ2NmY2NjAwMjJjODFmNGEiLCJ1c2VybmFtZSI6InJvaGFuIGt1bWFyIGphaW4iLCJlbWFpbCI6InJvaGFuQGdtYWlsLmNvbSIsImlhdCI6MTYxMzMyMDE4MiwiZXhwIjoxNjEzMzM4MTgyfQ.6ZlPsT4UeVD-RJNRNYDIuI4s58rJLdCfR04s_V5RzF4' \
--header 'Content-Type: application/json' \
--data-raw '{
"fileName":"IMG_b8d9rd.jpg"
}'
In curl, provide valid token and fileName(what ever file you want to delete) for proper execution.
Status: 200 OK
Content-Type: application/json
{"msg": "File Successfully Deleted!"}