mirror of
https://github.com/Grace-Solutions/PSMinIO.git
synced 2026-07-26 14:58:13 +00:00
b237838ff1
- Removed MinIO SDK dependency completely - Built custom HTTP client with AWS S3 signature v4 support - Created synchronous operations optimized for PowerShell - Added real progress reporting during transfers - Implemented performance metrics in result objects - Fixed null pointer warnings for code quality - Removed Write-Host usage from test scripts - Cleaned up unnecessary DLL dependencies Available cmdlets: - Connect-MinIO: Enhanced connection with certificate options - Get-MinIOBucket: List buckets with sorting and filtering - New-MinIOBucket: Create buckets with region support - Test-MinIOBucketExists: Check bucket existence - Get-MinIOObject: List objects with advanced filtering - New-MinIOObject: Upload files with real progress - Get-MinIOObjectContent: Download files with progress This represents a complete architectural overhaul for better PowerShell compatibility and performance.
71 lines
2.4 KiB
PowerShell
71 lines
2.4 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
<#
|
|
.SYNOPSIS
|
|
Quick test of PSMinIO upload and download functionality
|
|
|
|
.DESCRIPTION
|
|
Tests the new PSMinIO implementation with file upload and download
|
|
#>
|
|
|
|
# Import the module
|
|
Import-Module "$PSScriptRoot\..\Module\PSMinIO\PSMinIO.psd1" -Force
|
|
|
|
# Connect to MinIO
|
|
Write-Verbose "Connecting to MinIO..." -Verbose
|
|
Connect-MinIO -Endpoint "https://api.s3.gracesolution.info" -AccessKey "T34Wg85SAwezUa3sk3m4" -SecretKey "PxEmnbQoQJTJsDocSEV6mSSscDpJMiJCayPv93xe" -Verbose
|
|
|
|
# Create test file
|
|
$testFile = Join-Path $env:TEMP "psminiotest.txt"
|
|
$testContent = @"
|
|
PSMinIO Test File
|
|
================
|
|
Created: $(Get-Date)
|
|
Test data: $('A' * 1000)
|
|
"@
|
|
|
|
Write-Verbose "Creating test file: $testFile" -Verbose
|
|
$testContent | Out-File -FilePath $testFile -Encoding UTF8
|
|
$fileInfo = Get-Item $testFile
|
|
Write-Verbose "Test file created: $($fileInfo.Length) bytes" -Verbose
|
|
|
|
# Upload file
|
|
$testBucket = "psminiotest-20250711-142415"
|
|
Write-Verbose "Uploading file to bucket: $testBucket" -Verbose
|
|
$uploadResult = New-MinIOObject -BucketName $testBucket -File $fileInfo -PassThru -Verbose
|
|
|
|
Write-Output "Upload Result:"
|
|
if ($uploadResult) {
|
|
$uploadResult | Format-List ObjectName, TotalSizeFormatted, DurationFormatted, AverageSpeedFormatted, Success
|
|
}
|
|
|
|
# List objects
|
|
Write-Verbose "Listing objects in bucket..." -Verbose
|
|
$objects = Get-MinIOObject -BucketName $testBucket -Verbose
|
|
$objects | Format-Table Name, Size, LastModified
|
|
|
|
# Download file
|
|
$downloadFile = Join-Path $env:TEMP "psminiotest-download.txt"
|
|
Write-Verbose "Downloading file to: $downloadFile" -Verbose
|
|
$downloadResult = Get-MinIOObjectContent -BucketName $testBucket -ObjectName $fileInfo.Name -LocalPath $downloadFile -PassThru -Verbose
|
|
|
|
Write-Output "Download Result:"
|
|
if ($downloadResult) {
|
|
$downloadResult | Format-List ObjectName, TotalSizeFormatted, DurationFormatted, AverageSpeedFormatted, Success
|
|
}
|
|
|
|
# Verify content
|
|
$originalContent = Get-Content $testFile -Raw -ErrorAction SilentlyContinue
|
|
$downloadedContent = Get-Content $downloadFile -Raw -ErrorAction SilentlyContinue
|
|
|
|
if ($originalContent -and $downloadedContent -and ($originalContent -eq $downloadedContent)) {
|
|
Write-Output "✅ File content verification PASSED!"
|
|
} else {
|
|
Write-Output "❌ File content verification FAILED!"
|
|
}
|
|
|
|
# Cleanup
|
|
Remove-Item $testFile -Force -ErrorAction SilentlyContinue
|
|
Remove-Item $downloadFile -Force -ErrorAction SilentlyContinue
|
|
|
|
Write-Output "Test completed!"
|