# Sync repo-root uploads/ -> MinIO bucket prefix uploads/ (matches DB paths /uploads/...) # Requires MinIO Client: https://min.io/docs/minio/linux/reference/minio-mc.html # Run from repo root: # .\scripts\sync-uploads-to-minio.ps1 -McPath "D:\tools\mc.exe" # Optional params: -Endpoint -User -Password -Bucket -Alias param( [string] $Endpoint = "http://117.72.159.31:9000", [string] $User = "minioadmin", [string] $Password = "minioadmin", [string] $Bucket = "wuhan-saga", [string] $Alias = "wuhan-saga-remote", [string] $McPath = "" ) $ErrorActionPreference = "Stop" [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false) $root = Split-Path -Parent $PSScriptRoot if (-not (Test-Path -LiteralPath $root)) { $root = (Get-Location).Path } $uploads = Join-Path $root "uploads" if (-not (Test-Path -LiteralPath $uploads)) { Write-Host "Skip: no folder $uploads" exit 0 } $mcExe = $McPath if (-not [string]::IsNullOrWhiteSpace($mcExe)) { if (-not (Test-Path -LiteralPath $mcExe)) { throw "McPath not found: $mcExe" } } else { $tryLocal = Join-Path $root ".tools\mc.exe" if (Test-Path -LiteralPath $tryLocal) { $mcExe = $tryLocal } } if ([string]::IsNullOrWhiteSpace($mcExe)) { $mcCmd = Get-Command mc -ErrorAction SilentlyContinue if ($mcCmd) { $mcExe = $mcCmd.Source } } if ([string]::IsNullOrWhiteSpace($mcExe)) { throw "mc not found. Add to PATH, or place .tools/mc.exe, or pass -McPath. Download: https://dl.min.io/client/mc/release/windows-amd64/mc.exe" } Write-Host "Using mc: $mcExe" & $mcExe alias set $Alias $Endpoint $User $Password if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } & $mcExe mb "$Alias/$Bucket" --ignore-existing 2>$null Write-Host "Mirror: $uploads -> $Alias/$Bucket/uploads/" & $mcExe mirror --overwrite $uploads "$Alias/$Bucket/uploads" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host "Done. Check bucket $Bucket for uploads/banner etc."