Skip to content

chhavitekriwal/go-files

Repository files navigation

go-files

A simple file management system in Golang

Run Locally

Clone the project

  git clone https://github.com/chhavitekriwal/go-files.git
  cd go-files

Build and start the server

  go build
  ./go-files

API Reference

Base URL for local: http://127.0.0.1:8080

Register

  POST /register
Request
{
    "username": "userabc",
    "password": "abc1234"
}
Response
{
    "Message": "User registered and logged in",
    "Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXJhYmMiLCJleHAiOjE3MDI5MDc0OTYsImlhdCI6MTcwMjkwNTY5Nn0.CMGQDyfoe5Oe1nICoTFpdJoMHvblV6pHdLKoTM7FM6Y"
}

Login

  POST /login
Request
{
    "username": "userabc",
    "password": "abc1234"
}
Response
{
    "Message": "Logged in",
    "Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXJhYmMiLCJleHAiOjE3MDI5MDc1NjMsImlhdCI6MTcwMjkwNTc2M30.w2ta9UHGor8haAOcDRSzAzjr7O7NUnVE_lfFqSDtVto"
}

Upload

  POST /upload

image

Response
{
    "message": "Successfully uploaded",
    "filename": "xRsuEua.jpg",
    "size_in_bytes": 759085,
    "type": "image/jpeg"
}

Delete

  DELETE /delete?filename=F3000TEK.JPG
Response
{
    "message": "Successfully deleted"
}

List all files

  GET /files
Response
[
    {
        "filename": "Why_Phishing_works.pdf",
        "size_in_bytes": 1419266,
        "type": "application/pdf",
        "modified": "2023-12-18 04:31:43"
    },
    {
        "filename": "xRsuEua.jpg",
        "size_in_bytes": 759085,
        "type": "image/jpeg",
        "modified": "2023-12-18 19:04:08"
    }
]

Get file transactions

  GET /transactions
Response
[
    {
        "id": 23,
        "timestamp": "2023-12-18T19:01:18.900674321+05:30",
        "filename": "F0003TEK.JPG",
        "transaction_type": "DOWNLOAD",
        "username": "newuser"
    },
    {
        "id": 22,
        "timestamp": "2023-12-18T18:55:28.166416481+05:30",
        "filename": "F0003TEK.JPG",
        "transaction_type": "UPLOAD",
        "username": "newuser"
    },
    {
        "id": 21,
        "timestamp": "2023-12-18T18:34:08.089294576+05:30",
        "filename": "Social_Phishing.pdf",
        "transaction_type": "DELETE",
        "username": "newuser"
    }
]

About

A simple file system built in Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages