Skip to main content

File Access

API file access

Tip

Ensure you have completed the configuration steps Here


To share API files to unauthorised users by generating a token link

Get all access paths

Request

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

Response

{
"status": "String",
"return": "Number",
"url": "String",
"paths": "Array",
}

Response Validation

  1. status - response status
  1. return - Total paths
  1. url - file upload file with placeholders
  1. paths - Array containing all roles

Example

Response

{
"status": "success",
"return": 3,
"url": "http://localhost:5501/files/upload/<FILE_NAME>?grants=<TOKEN>&access=<FILE_ID>",
"paths": [
{
"_id": "62b4a67b7d5392f6d81a47cf",
"fileName": "one.pdf",
"authorizerID": "629ad74878103d4e4a74e9e6",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyOWFkNzQ4NzgxMDNkNGU0YTc0ZTllNiIsImNwYSI6IlRlY2hrZXkiLCJpYXQiOjE2NTYwMDYyNjcsImV4cCI6MTY1NjQzODI2N30.huf3QmBZA5FZQZ9ex1ZhrE0YucRhu--XHh1RdxPa8c8",
"maxviews": "2",
"private": true,
"expires": "2022-06-23T17:49:27.165Z",
"date": "2022-06-23T17:34:59.226Z",
"__v": 0
},
]
}

Add a access path

Request body

{
"name":"String",
"path":"String",
"maxviews":"String",
"private":"Boolean",
}

Body Validation

  1. name - File name
  1. path - File path
  1. maxviews - maximum times link can be used to view file
  1. private - set link to private and make use of maxviews option

Request

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

Response

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

Response Validation

  1. status - request status
  1. message - response message
  1. URL - access url

Example

Body

{
"name":"newname.pdf",
"path":"public/files/upload/newname.pdf",
"maxviews":"4",
"private":true
}

Response

{
"status": "success",
"mesage": "Access the file through",
"URL": "http://localhost:5501/files/upload/newname.pdf?grants=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyOWFkNzQ4NzgxMDNkNGU0YTc0ZTllNiIsImNwYSI6IlRlY2hrZXkiLCJpYXQiOjE2NTgxNjQ3NzAsImV4cCI6MTY1ODU5Njc3MH0.7KH4THg6o1rVjMCcPow8l6vInZOL_NJQBz38TqGSm_Y&access=62d59622f3c448893364a066"
}

Update access path

Request body

{
"id":"String",
"maxviews":"String",
"private": "Boolean"
}

Body Validation

  1. id - Access path ID
  1. maxviews - maximum times link can be used to view file
  1. private - set link to private and make use of maxviews option

Request

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

Response

{
"status": "String",
"data": "Object"
}

Response Validation

  1. status - request status
  1. data - access path ID

Example

Body

{
"maxviews":"4",
"id":"62b4a67b7d5392f6d81a47cf",
"private":false
}

Response

{
"status": "success",
"data": "62b4a67b7d5392f6d81a47cf"
}

Delete access path

Request

DELETE
http://localhost:5501/api/v1/file/public/<ACCESS_PATH_ID>

Response