mirror of
https://github.com/Grace-Solutions/PSMinIO.git
synced 2026-07-26 14:58:13 +00:00
f420effc84
✅ ZipArchiveBuilder - Core compression engine: • Built on System.IO.Compression (.NET Standard 2.0 built-in) • Real-time progress tracking with events • Start/end time tracking with duration calculation • Size metrics (compressed/uncompressed) and compression ratios • FileSystemInfo support (FileInfo, DirectoryInfo) • Append support via ZipArchiveMode.Update • Compression efficiency calculations ✅ ZipBuilder - PowerShell integration layer: • ThreadSafeProgressCollector integration • Multi-layer progress tracking (Zip + File levels) • Verbose logging with comprehensive metrics • ZipCreationResult object for PowerShell output • Event-driven progress reporting ✅ New-MinIOZipArchive cmdlet - Well-structured PowerShell interface: • Files parameter set: FileInfo[] support for multiple files • Directory parameter set: DirectoryInfo with recursive options • File filtering: InclusionFilter/ExclusionFilter ScriptBlocks • Compression levels: Optimal, Fastest, NoCompression • Archive modes: Create, Update (for appending) • BasePath parameter for custom entry name control • Force parameter for overwriting existing archives • PassThru parameter for detailed result objects ✅ Advanced features: • Progress tracking: Real-time speed and ETA calculations • Metrics: Compression ratio, space saved, processing time • File filtering: ScriptBlock-based inclusion/exclusion • Path handling: Cross-platform compatibility • Error handling: Comprehensive validation and recovery • Memory efficiency: 80KB buffer for optimal throughput ✅ Integration benefits: • No external dependencies (uses built-in .NET compression) • Thread-safe operations compatible with PSMinIO architecture • Consistent with existing progress tracking patterns • Minimal footprint aligning with project preferences • Enterprise-grade functionality with comprehensive metrics Architecture: Built on System.IO.Compression with custom progress tracking, providing superior zip functionality with PowerShell-native integration.
118 lines
5.2 KiB
PowerShell
118 lines
5.2 KiB
PowerShell
# Test script for current upload functionality (single file version)
|
|
param(
|
|
[string]$TestBucketName = "psminiotest-current-$(Get-Date -Format 'yyyyMMdd-HHmmss')",
|
|
[switch]$Cleanup,
|
|
[switch]$Verbose
|
|
)
|
|
|
|
if ($Verbose) {
|
|
$VerbosePreference = 'Continue'
|
|
}
|
|
|
|
Write-Host "=== PSMinIO Current Upload Test ===" -ForegroundColor Cyan
|
|
Write-Host "Testing current upload functionality" -ForegroundColor Green
|
|
|
|
try {
|
|
# Import the module
|
|
Write-Host "`n1. Loading PSMinIO module..." -ForegroundColor Yellow
|
|
Import-Module ".\Module\PSMinIO\PSMinIO.psd1" -Force
|
|
|
|
# Connect to MinIO
|
|
Write-Host "2. Connecting to MinIO..." -ForegroundColor Yellow
|
|
Connect-MinIO -Endpoint "https://api.s3.gracesolution.info" -AccessKey "T34Wg85SAwezUa3sk3m4" -SecretKey "PxEmnbQoQJTJsDocSEV6mSSscDpJMiJCayPv93xe"
|
|
Write-Host "✅ Connected successfully!" -ForegroundColor Green
|
|
|
|
# Create test files
|
|
Write-Host "`n3. Creating test files..." -ForegroundColor Yellow
|
|
$testDir = "TestFilesCurrent"
|
|
if (Test-Path $testDir) {
|
|
Remove-Item $testDir -Recurse -Force
|
|
}
|
|
New-Item -ItemType Directory -Path $testDir -Force | Out-Null
|
|
|
|
# Create 10 test files
|
|
$testFiles = @()
|
|
for ($i = 1; $i -le 10; $i++) {
|
|
$fileName = "testfile-{0:D3}.txt" -f $i
|
|
$filePath = Join-Path $testDir $fileName
|
|
$content = "Test file $i - $(Get-Date)`n" + ("Content line $i`n" * 10)
|
|
Set-Content -Path $filePath -Value $content
|
|
$testFiles += Get-Item $filePath
|
|
}
|
|
|
|
Write-Host "✅ Created 10 test files" -ForegroundColor Green
|
|
|
|
# Create test bucket
|
|
Write-Host "`n4. Creating test bucket: $TestBucketName" -ForegroundColor Yellow
|
|
New-MinIOBucket -BucketName $TestBucketName
|
|
Write-Host "✅ Bucket created successfully!" -ForegroundColor Green
|
|
|
|
# Test uploading files one by one (current functionality)
|
|
Write-Host "`n5. Uploading files individually..." -ForegroundColor Yellow
|
|
$uploadResults = @()
|
|
$uploadStart = Get-Date
|
|
|
|
foreach ($file in $testFiles) {
|
|
Write-Host " Uploading: $($file.Name)" -ForegroundColor Cyan
|
|
$result = New-MinIOObject -BucketName $TestBucketName -File $file -BucketDirectory "individual-uploads" -PassThru -Verbose
|
|
$uploadResults += $result
|
|
}
|
|
|
|
$uploadDuration = (Get-Date) - $uploadStart
|
|
Write-Host "✅ Upload completed in $($uploadDuration.TotalSeconds.ToString('F2')) seconds!" -ForegroundColor Green
|
|
Write-Host " Files uploaded: $($uploadResults.Count)" -ForegroundColor Green
|
|
|
|
# Verify uploads
|
|
Write-Host "`n6. Verifying uploads..." -ForegroundColor Yellow
|
|
$objects = Get-MinIOObject -BucketName $TestBucketName
|
|
Write-Host "✅ Found $($objects.Count) objects in bucket" -ForegroundColor Green
|
|
|
|
# Test with different bucket directories
|
|
Write-Host "`n7. Testing nested bucket directories..." -ForegroundColor Yellow
|
|
$nestedResults = @()
|
|
foreach ($file in $testFiles[0..2]) { # Upload first 3 files to nested structure
|
|
$result = New-MinIOObject -BucketName $TestBucketName -File $file -BucketDirectory "level1/level2/level3" -PassThru -Verbose
|
|
$nestedResults += $result
|
|
}
|
|
Write-Host "✅ Nested directory upload completed: $($nestedResults.Count) files" -ForegroundColor Green
|
|
|
|
# Final verification
|
|
Write-Host "`n8. Final verification..." -ForegroundColor Yellow
|
|
$allObjects = Get-MinIOObject -BucketName $TestBucketName
|
|
$individualObjects = $allObjects | Where-Object { $_.Name -like "individual-uploads/*" }
|
|
$nestedObjects = $allObjects | Where-Object { $_.Name -like "level1/level2/level3/*" }
|
|
|
|
Write-Host "✅ Final verification complete:" -ForegroundColor Green
|
|
Write-Host " Total objects: $($allObjects.Count)" -ForegroundColor Green
|
|
Write-Host " Individual uploads: $($individualObjects.Count)" -ForegroundColor Green
|
|
Write-Host " Nested uploads: $($nestedObjects.Count)" -ForegroundColor Green
|
|
|
|
# Summary
|
|
Write-Host "`n=== TEST SUMMARY ===" -ForegroundColor Cyan
|
|
Write-Host "✅ Current functionality test completed!" -ForegroundColor Green
|
|
Write-Host "Features tested:" -ForegroundColor Yellow
|
|
Write-Host " • Single file upload with File parameter" -ForegroundColor White
|
|
Write-Host " • BucketDirectory parameter for nested structures" -ForegroundColor White
|
|
Write-Host " • PassThru parameter for upload results" -ForegroundColor White
|
|
Write-Host " • Multiple individual uploads" -ForegroundColor White
|
|
Write-Host " • Nested directory structure creation" -ForegroundColor White
|
|
|
|
Write-Host "`nNote: Enhanced features (FileInfo[], Directory, Multi-layer progress) require updated DLL" -ForegroundColor Yellow
|
|
|
|
if ($Cleanup) {
|
|
Write-Host "`n9. Cleaning up..." -ForegroundColor Yellow
|
|
Remove-MinIOBucket -BucketName $TestBucketName -Force
|
|
Write-Host "✅ Cleanup completed!" -ForegroundColor Green
|
|
}
|
|
|
|
} catch {
|
|
Write-Host "❌ Test failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
Write-Host "Stack trace: $($_.ScriptStackTrace)" -ForegroundColor Red
|
|
} finally {
|
|
if (Test-Path $testDir) {
|
|
Remove-Item $testDir -Recurse -Force -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
|
|
Write-Host "`n=== Test Complete ===" -ForegroundColor Cyan
|