Compare commits
2 Commits
efc1156390
...
5d2a1b2688
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d2a1b2688 | |||
| fc2510b567 |
56
scripts/sync-uploads-to-minio.ps1
Normal file
56
scripts/sync-uploads-to-minio.ps1
Normal file
@@ -0,0 +1,56 @@
|
||||
# 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."
|
||||
@@ -21,7 +21,7 @@ upload:
|
||||
|
||||
minio:
|
||||
endpoint: http://127.0.0.1:9000
|
||||
access-key: klp
|
||||
secret-key: ruoyi123
|
||||
access-key: minioadmin
|
||||
secret-key: minioadmin
|
||||
bucket: wuhan-saga
|
||||
region: us-east-1
|
||||
|
||||
@@ -56,18 +56,18 @@ knife4j:
|
||||
setting:
|
||||
language: zh_cn
|
||||
|
||||
# 存储:local=本机 uploads | minio=对象存储,见 server/deploy/minio-spring-config.example.yml
|
||||
# 存储:local=本机 uploads | minio=对象存储(9000 为 API,不是控制台 9001)
|
||||
# 密钥可用环境变量覆盖:MINIO_ACCESS_KEY、MINIO_SECRET_KEY(勿将生产密码提交到公开仓库)
|
||||
upload:
|
||||
storage: minio
|
||||
path: uploads/
|
||||
allowed-types: image/jpeg,image/png,image/gif,image/webp,image/svg+xml,video/mp4,video/webm
|
||||
max-size: 52428800
|
||||
|
||||
# 仅 upload.storage=minio 时生效;密钥用环境变量注入,勿提交生产明文
|
||||
minio:
|
||||
endpoint: http://minio:9000
|
||||
access-key: minioadmin
|
||||
secret-key: minioadmin
|
||||
endpoint: http://117.72.159.31:9000
|
||||
access-key: ${MINIO_ACCESS_KEY:minioadmin}
|
||||
secret-key: ${MINIO_SECRET_KEY:minioadmin}
|
||||
bucket: wuhan-saga
|
||||
region: us-east-1
|
||||
|
||||
|
||||
@@ -56,18 +56,18 @@ knife4j:
|
||||
setting:
|
||||
language: zh_cn
|
||||
|
||||
# 存储:local=本机 uploads | minio=对象存储,见 server/deploy/minio-spring-config.example.yml
|
||||
# 存储:local=本机 uploads | minio=对象存储(9000 为 API,不是控制台 9001)
|
||||
# 密钥可用环境变量覆盖:MINIO_ACCESS_KEY、MINIO_SECRET_KEY(勿将生产密码提交到公开仓库)
|
||||
upload:
|
||||
storage: local
|
||||
storage: minio
|
||||
path: uploads/
|
||||
allowed-types: image/jpeg,image/png,image/gif,image/webp,image/svg+xml,video/mp4,video/webm
|
||||
max-size: 52428800
|
||||
|
||||
# 仅 upload.storage=minio 时生效;密钥用环境变量注入,勿提交生产明文
|
||||
minio:
|
||||
endpoint: http://127.0.0.1:9000
|
||||
access-key: minioadmin
|
||||
secret-key: minioadmin
|
||||
endpoint: http://117.72.159.31:9000
|
||||
access-key: ${MINIO_ACCESS_KEY:minioadmin}
|
||||
secret-key: ${MINIO_SECRET_KEY:minioadmin}
|
||||
bucket: wuhan-saga
|
||||
region: us-east-1
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user