Skip to content

💪💪 Storage is calculates the size of files under a directory and returns them in JSON format.

License

Notifications You must be signed in to change notification settings

chidoriashi1990/storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Storage

💪💪 Storage is calculates the size of files under a directory and returns them in JSON format.

How use it?

Running the server

$ go run main.go

Build & Run server

$ go build .
$ storage.exe

Using Docker Compose

The Docker Compose file consists of the following.

version: '3'

services: 
  storage:
    build: 
      context: ./
      dockerfile: ./Dockerfile
    image: storage-scale:0.1.0
    container_name: storage-scale
    ports:
      - 8080:8080
    environment:
        # Specify the origin to allow access to the resource
        ACCESS_CONTROL_ALLOW_ORIGIN: "http://localhost"
        # Specifies the base path of the directory to search
        BASE_DIR: "/share/misc"
        # Separate files and paths to exclude from the search, separated by commas
        EXCLUDE: ignore,ignore2
        # If the debug mode is set to true, the standard output shows the number, file name and file size (in bytes).
        # Example.
        #   No.1 .dockerignore 19 byte
        #   No.2 api/swagger.yaml 2420 byte
        IS_DEBUG_MODE: "false"
    # Specify the directory you want to search for in volume
    volumes: 
      - /tmp:/share/misc

Start the container with the following command and request URL (https://localhost :8080/v1/weight).

$ docker-compose build
$ docker-compose up -d

cURL

curl -i -X POST \
   -H "Content-Type:application/json" \
   -H "Accept:application/json" \
   -d \
'{
  "target_path": "/scales",
  "ignore_paths": [
    	".git",
    	".DS_Store",
    	"__debug_bin"
  ]
}' \
 'http://localhost:8080/v1/weight'

Response

{
    "base_dir": "/tmp/storage",
    "exclude":[],
    "ignore":[
        ".git",
        ".DS_Store",
        "__debug_bin"
    ],
    "target": "/tmp/storage/scales",
    "total":{
        "b": 18847,
        "gb": 0.000017552637,
        "kb": 18.405273,
        "mb": 0.0179739
    }
}

Document

Import the following YAML file into the Swagger Editor.

LICENSE

MIT

About

💪💪 Storage is calculates the size of files under a directory and returns them in JSON format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published