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 : []byte
In this format,
file
is a byte array of the actual file. uploads file in filesystem.
output format :
-
json :
successful upload :
{ "download_url" : "string" }
download_url
is the path of saved file in filesystem.failure upload :
{ "error" : "string" }
error
is a description of the occurred error.
-
json :
{ "download_url" : "string" }
In this format,
download_url
is 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" }
error
is a description of the occurred error.
- json :
{ "download_url" : "string", "user_to_be_add" : "string" }