Skip to content

[WIP 👷] Share instantaneously files and pictures

License

Notifications You must be signed in to change notification settings

Themimitoof/krin

Repository files navigation

Krin: Share instantaneously files and pictures

Krin is a simple server that host files and pictures for sharing instantaneously with your collegues or your friends built in NodeJS and SQLite. It can be used by multiple users by creating new API key for each person.

Prerequisites

You only need to have Node.JS installed on your machine.

Docker installation

WIP

Manual installation

WIP

Usage

Routes

GET /files

Headers:

  • X-Api-Key: user's api key
  • (optionnal) Content-type: return the error message in JSON if the value is application/json, otherwise is return in plain text.

Return: Return the link to the file.

POST /files

Headers:

  • X-Api-Key: user's api key
  • (optionnal) Expires-At: expiration date of the ressource in RFC2822 or ISO8601 format.

Return: Return the list of user's files.

GET /files/:filename

Headers:

  • (optionnal) Content-type: return the error message in JSON if the value is application/json, otherwise is return in plain text.

Return: Return the requested file or error message.

DELETE /files/:filename

Headers:

  • X-Api-Key: user's api key
  • (optionnal) Content-type: return the error message in JSON if the value is application/json, otherwise is return in plain text.

Return: Return validation message or error message.

Examples

Get users file list

curl -H "X-Api-Key: <my_api_key>" http://<link_to_my_instance>/files

Return:

[
    {
        "uuid": "2bfe71af-3ca5-4c2b-a148-da1eb1b88b36",
        "file": "2732b422634229d30187ea25a930af13.jpg",
        "owner": "4faa8b88-d63b-11e8-9f8b-f2801f1b9fd1",
        "expireAt": null,
        "createdAt": "2018-10-31 08:07:22.760 +00:00",
        "updatedAt": "2018-10-31 08:07:22.760 +00:00"
    },
    ...
]

Uploading a file with cURL

curl -X POST -H "X-Api-Key: <my_api_key>" -d @<file> http://<link_to_my_instance>/files

Return: http://<link_to_my_instance>/files/fkjldsjlkdsjklsdjflkdsjklsdjfs

Uploading a file with cURL and return in JSON:

curl -X POST -H "X-Api-Key: <my_api_key>" -H "Content-type: application/json" -d @<file> http://<link_to_my_instance>/files

Return:

{
    "code": 200,
    "message": "http://<link_to_my_instance>/files/fkjldsjlkdsjklsdjflkdsjklsdjfs"
}

Uploading a file with expiration date with cURL

curl -X POST -H "X-Api-Key: <my_api_key>" -H "Expires-At: Mon, Dec 24 2018 23:59:59 GMT" -d @<file> http://<link_to_my_instance>/files

Return: http://<link_to_my_instance>/files/enzjrkzenrezkjrnezjknrzjke

Delete a file with cURL

curl -X DELETE -H "X-Api-Key: <my_api_key>" http://<link_to_my_instance>/files/<file_name>

Return: File deleted

Delete a file with cURL and return in JSON

curl -X DELETE -H "X-Api-Key: <my_api_key>" -H "Content-type: application/json" -d @<file> http://<link_to_my_instance>/files/<file_name>

Return:

{
    "code": 200,
    "message": "File deleted"
}

Command lines

WIP

Limitation

Today, Krin uses file-type module to determine the MIME type and the extension of the file. If is not recognized by the module, it fallback automaticaly to application/octet-stream.

Contribution

Feel free to contribute to the project by creating issues or merge request for implementing new features or patch bug.

License

Krin is released with MIT License.

Releases

No releases published

Packages

No packages published