Files
PSMinIO/scripts/examples/01-Basic-Operations.ps1
T
PSMinIO Developer 90c64d3237 Major project reorganization: Centralized version management and improved structure
- Reorganized project structure with proper directory separation:
  * All scripts moved to scripts/ directory (including examples)
  * All documentation moved to docs/ directory (except README.md)
  * Centralized version management in Version.ps1

- Implemented centralized version management system:
  * Version.ps1 provides single source of truth for version information
  * Automatic yyyy.MM.dd.HHmm versioning based on build time
  * scripts/Update-Version.ps1 updates all version references
  * src/Properties/AssemblyInfo.cs for assembly version information

- Enhanced build system:
  * scripts/Build.ps1 - Full build with validation and packaging
  * scripts/Quick-Build.ps1 - Fast build handling file locking issues
  * Removed automatic copy from project file to avoid locking
  * Integrated version updates into build process

- Updated PowerShell Gallery publishing:
  * scripts/Publish-PSMinIOToGallery.ps1 updated for new structure
  * docs/POWERSHELL-GALLERY-RELEASE.md comprehensive publishing guide
  * Module manifest updated with proper metadata and release notes

- Updated all documentation and examples:
  * README.md updated with PowerShell Gallery installation
  * All example scripts updated with correct import paths
  * scripts/examples/README.md updated for new location
  * docs/PROJECT-STRUCTURE.md documents new organization

- Version updated to 2025.07.11.1151 with centralized management
- All import paths corrected for new structure
- Professional project organization following PowerShell best practices
2025-07-11 11:53:08 -04:00

72 lines
2.7 KiB
PowerShell

# PSMinIO Basic Operations Example
# This script demonstrates fundamental MinIO operations using PSMinIO
# Import the module
Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1
# Example connection details (replace with your actual values)
$endpoint = "https://minio.example.com"
$accessKey = "your-access-key"
$secretKey = "your-secret-key"
try {
# Connect to MinIO server
$connection = Connect-MinIO -Endpoint $endpoint -AccessKey $accessKey -SecretKey $secretKey
"Connected to MinIO server: $endpoint"
# List all buckets
"Listing all buckets..."
$buckets = Get-MinIOBucket
$buckets | Format-Table Name, CreationDate, @{Name="Objects";Expression={"N/A"}}
# Create a new bucket
$bucketName = "example-bucket-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
"Creating bucket: $bucketName"
New-MinIOBucket -BucketName $bucketName
# Verify bucket creation
if (Test-MinIOBucketExists -BucketName $bucketName) {
"✅ Bucket '$bucketName' created successfully"
}
# Create a sample file for upload
$sampleFile = "sample-document.txt"
"This is a sample document created on $(Get-Date)" | Out-File -FilePath $sampleFile -Encoding UTF8
# Upload the file
"Uploading file: $sampleFile"
$uploadResult = New-MinIOObject -BucketName $bucketName -Files $sampleFile
$uploadResult | Format-Table Name, @{Name="Duration";Expression={$_.Duration}}, @{Name="Speed";Expression={$_.AverageSpeedFormatted}}
# List objects in the bucket
"Listing objects in bucket '$bucketName':"
$objects = Get-MinIOObject -BucketName $bucketName
$objects | Format-Table Name, @{Name="Size";Expression={"$($_.Size) bytes"}}, LastModified
# Download the file
$downloadPath = "downloaded-$sampleFile"
"Downloading file to: $downloadPath"
$downloadResult = Get-MinIOObjectContent -BucketName $bucketName -ObjectName $sampleFile -FilePath $downloadPath
$downloadResult | Format-Table @{Name="LocalFile";Expression={$_.FilePath.Name}}, @{Name="Duration";Expression={$_.Duration}}, @{Name="Speed";Expression={$_.AverageSpeedFormatted}}
# Verify download
if (Test-Path $downloadPath) {
"✅ File downloaded successfully"
"Content: $(Get-Content $downloadPath)"
}
# Clean up
"Cleaning up..."
Remove-MinIOObject -BucketName $bucketName -ObjectName $sampleFile -Force
Remove-MinIOBucket -BucketName $bucketName -Force
Remove-Item $sampleFile, $downloadPath -Force -ErrorAction SilentlyContinue
"✅ Basic operations completed successfully"
} catch {
"❌ Error: $($_.Exception.Message)"
} finally {
# Clean up any remaining files
Remove-Item "sample-document.txt", "downloaded-sample-document.txt" -Force -ErrorAction SilentlyContinue
}