Created
September 7, 2016 18:00
-
-
Save pmolchanov/1d0aae12bb009b88aa43b447168b4206 to your computer and use it in GitHub Desktop.
Quick n Dirty S3 Upload/Download for Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Upload | |
&{ | |
$ErrorActionPreference = 'Stop' | |
$AWSRegion = "us-east-1" | |
$AWSAccessKeyId = "TODO: Access Key" | |
$AWSSecretAccessKey = "TODO: Secret Access Key" | |
$BucketName = "TODO: Bucket Name" | |
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null | |
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog | |
$OpenFileDialog.ShowDialog() | Out-Null | |
Write-S3Object -BucketName $BucketName -Key "upload.s3" -File $OpenFileDialog.FileName -Region "$AWSRegion" -AccessKey "$AWSAccessKeyId" -SecretKey "$AWSSecretAccessKey" | |
} | |
# Download | |
&{ | |
$ErrorActionPreference = 'Stop' | |
$AWSRegion = "us-east-1" | |
$AWSAccessKeyId = "TODO: Access Key" | |
$AWSSecretAccessKey = "TODO: Secret Access Key" | |
$BucketName = "TODO: Bucket Name" | |
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null | |
$FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog | |
$FolderBrowserDialog.ShowDialog() | Out-Null | |
$File = [System.IO.Path]::Combine($FolderBrowserDialog.SelectedPath,"download.s3") | |
Read-S3Object -BucketName $BucketName -Key "upload.s3" -File $File -Region "$AWSRegion" -AccessKey "$AWSAccessKeyId" -SecretKey "$AWSSecretAccessKey" | |
Remove-S3Object -BucketName $BucketName -Key "upload.s3" -Force -Region "$AWSRegion" -AccessKey "$AWSAccessKeyId" -SecretKey "$AWSSecretAccessKey" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment