Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Endpoint: DELETE /api/files/delete/{filename}

  • Headers: None

  • Response: Confirmation message.

Export “File Management API.postman_collection.json“ into postman
Elite soft json viewer
modeCode
hideMenutrue
hideBordertrue
{
	"info": {
		"_postman_id": "442dfc38-0352-4b0c-ba1f-79b40a9f5386",
		"name": "File Management API",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "31031320",
		"_collection_link": "https://cps999-2753.postman.co/workspace/cps-Workspace~2d457640-a1d5-492a-9918-6eae800aacc2/collection/31031320-442dfc38-0352-4b0c-ba1f-79b40a9f5386?action=share&source=collection_link&creator=31031320"
	},
	"item": [
		{
			"name": "File Upload",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "multipart/form-data"
					}
				],
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "file",
							"type": "file",
							"src": "/C:/Users/SourabhSourabh/Downloads/jdk-17.0.12_windows-x64_bin.exe"
						}
					]
				},
				"url": {
					"raw": "{{base_url}}/api/files/upload",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"api",
						"files",
						"upload"
					]
				}
			},
			"response": []
		},
		{
			"name": "List Files",
			"request": {
				"method": "GET",
				"header": [],
				"url": {
					"raw": "{{base_url}}/api/files/list?base_url=http://localhost:8000",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"api",
						"files",
						"list"
					],
					"query": [
						{
							"key": "base_url",
							"value": "http://localhost:8000"
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "Download File",
			"request": {
				"method": "GET",
				"header": [],
				"url": {
					"raw": "{{base_url}}/api/files/download/{{filename}}",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"api",
						"files",
						"download",
						"{{filename}}"
					],
					"variable": [
						{
							"key": "filename",
							"value": ""
						}
					]
				}
			},
			"response": []
		},
		{
			"name": "Delete File",
			"request": {
				"method": "DELETE",
				"header": [],
				"url": {
					"raw": "{{base_url}}/api/files/delete/{{filename}}",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"api",
						"files",
						"delete",
						"{{filename}}"
					],
					"variable": [
						{
							"key": "filename",
							"value": "Screenshot 2024-11-12 133157.png"
						}
					]
				}
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "base_url",
			"value": "http://localhost:8080",
			"type": "string"
		}
	]
}

...

Erasure coding protects data from drive failures by splitting and storing data across multiple drives.

Steps:

...

Info

Create the Docker Volumes (if not created yet):

Before running the modified command, ensure that you have created the Docker volumes if they don't exist:

Code Block
languagepowershell
docker 

...

volume 

...

Simulate a disk failure by stopping one volume:

...

create minio_volume1 
docker volume create minio_volume2 
docker volume create minio_volume3 
docker volume create minio_volume4

After running the command, MinIO will be using the Docker volumes instead of local disk directories for its data storage.

  1. Modify the Docker setup to enable erasure coding:

    Code Block
    languagepowershell
    docker run -p 9000:9000 -p 9001:9001 \
        -e "MINIO_ROOT_USER=YOUR_ACCESS_KEY" \
        -e "MINIO_ROOT_PASSWORD=YOUR_SECRET_KEY" \
        --name minio \
        -v minio_volume1:/data1 \
        -v minio_volume2:/data2 \
        -v minio_volume3:/data3 \
        -v minio_volume4:/data4 \
        -v $(pwd)/config:/root/.minio \
        minio/minio server /data1 /data2 /data3 /data4 --console-address ":9001"
  2. Simulate a disk failure by stopping one volume:

Info

Steps for Simulating the Disk Failure:

  1. Identify the Volume: First, identify the Docker volume being used by MinIO for data storage. This is necessary to understand where the data resides and which volume is being used.

    Code Block
    docker volume ls

    This will list all the Docker volumes. You should see the volume used by MinIO, such as minio_volume1, minio_volume2, etc.

  2. Find the Mount Path for the Volume: Inspect the volume to get its mount path on the host machine:

    Code Block
    docker volume inspect minio_volume1

    Look for the "Mountpoint" field in the output, which indicates where the volume is mounted on the host.

  1. Code Block
    Go to Files tab into minio container select the data volume, right click and delete it
    image-20250121-152222.pngImage Added

    image-20250121-152302.pngImage Added

  2. Test file uploads/downloads using the existing Spring Boot APIs to observe no data loss.

Info

Command Structure:

1. docker run:

Runs a container from a Docker image.

2. -p 9000:9000 -p 9001:9001:

Maps ports on the host to ports in the container:

  • 9000:9000 → Maps the host's port 9000 to the container's port 9000 (used for the MinIO API).

  • 9001:9001 → Maps the host's port 9001 to the container's port 9001 (used for the MinIO web console).

3. -e "MINIO_ROOT_USER=YOUR_ACCESS_KEY":

Sets the environment variable MINIO_ROOT_USER inside the container to YOUR_ACCESS_KEY. This is the access key for authentication.

4. -e "MINIO_ROOT_PASSWORD=YOUR_SECRET_KEY":

Sets the environment variable MINIO_ROOT_PASSWORD inside the container to YOUR_SECRET_KEY. This is the secret key for authentication.

5. --name minio:

Assigns the name minio to the container. You can reference the container by this name for future commands.

6. -v /mnt/disk1:/data1 to -v /mnt/disk4:/data4:

Mounts the host's directories (/mnt/disk1, /mnt/disk2, etc.) to directories in the container (/data1, /data2, etc.). These are storage volumes for MinIO.

7. minio/minio:

Specifies the Docker image to use, which in this case is the official MinIO image.

8. server /data{1...4}:

  • Runs the MinIO server in distributed mode, using the specified directories (/data1, /data2, /data3, /data4) as storage locations.

  • The {1...4} syntax expands to /data1 /data2 /data3 /data4.


Summary:

This command starts a MinIO server in distributed mode with:

  1. Two exposed ports (9000 for API, 9001 for the web console).

  2. Authentication credentials provided via environment variables.

  3. Four storage volumes mapped from host directories.

  4. The MinIO container named minio.

...

2. Bitrot Protection

MinIO uses checksums to detect and repair corrupted data.

...