You are to use gin framework package and concurrency in golang and jwt-go to implement a simple http server. You should implement an rest api with authentication on some endpoints to upload or download a file. All registered users can upload and download files. no user can download other user's files. users can give access to other specific users to download their files. REST APIs that you should implement are listed below:
- json :
create new user
{ "username" : "string", "password" : "string" }
- json :
logins and gives access token
{ "username" : "string", "password" : "string" }
input formats :
-
form :
file : []byteIn this format,
fileis a byte array of the actual file. uploads file in filesystem.
output format :
-
json :
successful upload :
{ "download_url" : "string" }download_urlis the path of saved file in filesystem.failure upload :
{ "error" : "string" }erroris a description of the occurred error.
-
json :
{ "download_url" : "string" }In this format,
download_urlis an id that we got in successful upload request. it will download the file if user has download premission.
output format :
-
json :
successful download :
http response with actual file
failure download :{ "error" : "string" }erroris a description of the occurred error.
- json :
{ "download_url" : "string", "user_to_be_add" : "string" }