Skip to main content

Files

API files

Tip

Ensure you have completed the configuration steps Here


How to manipulate the Express.js File manager

Get all Files

Request

GET
http://localhost:5501/api/v1/file

Response

{
"status": "String",
"filesDetails": "Array"
}

Response Validation

  1. status - response status
  1. filesDetails - Array containing all files and their details

Example

Response

{
"status": "success",
"filesDetails": [
{
"size": 153926,
"name": "selfie.png",
"path": "public/files/upload/selfie.png",
"ext": ".png",
"isDirectory": false,
"isImage": true,
"isMedia": false,
"date": "2022-06-24T07:02:15.697Z"
}
]
}

Add a new File

Request Form-Data

file: Any

Body Validation

  1. file - any file with any format

Request

POST
http://localhost:5501/api/v1/file

Response

{
"status": "String",
"message": "String"
}

Response Validation

  1. status - request status
  1. message - response message

Example

Form-Data

file: hello.pdf

Response

{
"status": "success",
"mesage": "file uploaded"
}

Update File

Request body

{
"name":"String",
"path":"String",
"rename":"Array"
}

Body Validation

  1. name - file name
  1. path - file path
  1. rename - new file name

Request

PATCH
http://localhost:5501/api/v1/file

Response

{
"status": "String",
"message": "String"
}

Response Validation

  1. status - request status
  1. message - response message

Example

Body

{
"name":"ahaa.pdf",
"path":"public/files/upload/ahaa.pdf",
"rename":"myphoto"
}

Response

{
"status": "success",
"mesage": "File Renamed"
}

Delete File

Request body

{
"name":"String",
"path":"String"
}

Body Validation

  1. name - file name
  1. path - file path

Request

DELETE
http://localhost:5501/api/v1/file

Response

{
"status": "String",
"message": "String"
}

Response Validation

  1. status - request status
  1. message - response message

Example

Body

{
"name":"myphoto.pdf",
"path":"public/files/upload/myphoto.pdf"
}

Response

{
"status": "success",
"mesage": "File removed"
}