Skip to content

Commit

Permalink
!deploy v2.6.3 - resolve issue #51
Browse files Browse the repository at this point in the history
#### 2.6.3

* Fixed: `Export-GSDriveFile -OutFilePath C:\doc.pdf -Type PDF` failing due to incorrect parameter validation.  ([Issue #51](#51))
  • Loading branch information
scrthq committed Jun 9, 2018
2 parents 16e55a7 + 5c5dc40 commit 85f4070
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 52 deletions.
57 changes: 31 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,40 @@
<!-- TOC -->

- [Changelog](#changelog)
- [2.6.2](#262)
- [2.6.1](#261)
- [2.6.0](#260)
- [2.5.4](#254)
- [2.5.3](#253)
- [2.5.2](#252)
- [2.5.1](#251)
- [2.5.0](#250)
- [2.4.0](#240)
- [2.3.0](#230)
- [2.2.1](#221)
- [2.2.0](#220)
- [2.1.5](#215)
- [2.1.3 / 2.1.4](#213---214)
- [2.1.2](#212)
- [2.1.1](#211)
- [2.1.0](#210)
- [2.0.3](#203)
- [2.0.2](#202)
- [2.0.1](#201)
- [2.0.0](#200)
- [New Functionality](#new-functionality)
- [Breaking Changes in 2.0.0](#breaking-changes-in-200)
- [Gmail Delegation Management Removed](#gmail-delegation-management-removed)
- [Functions Removed](#functions-removed)
- [Functions Aliased](#functions-aliased)
- [2.6.3](#263)
- [2.6.2](#262)
- [2.6.1](#261)
- [2.6.0](#260)
- [2.5.4](#254)
- [2.5.3](#253)
- [2.5.2](#252)
- [2.5.1](#251)
- [2.5.0](#250)
- [2.4.0](#240)
- [2.3.0](#230)
- [2.2.1](#221)
- [2.2.0](#220)
- [2.1.5](#215)
- [2.1.3 / 2.1.4](#213--214)
- [2.1.2](#212)
- [2.1.1](#211)
- [2.1.0](#210)
- [2.0.3](#203)
- [2.0.2](#202)
- [2.0.1](#201)
- [2.0.0](#200)
- [New Functionality](#new-functionality)
- [Breaking Changes in 2.0.0](#breaking-changes-in-200)
- [Gmail Delegation Management Removed](#gmail-delegation-management-removed)
- [Functions Removed](#functions-removed)
- [Functions Aliased](#functions-aliased)

<!-- /TOC -->

## 2.6.3

* Fixed: `Export-GSDriveFile -OutFilePath C:\doc.pdf -Type PDF` failing due to incorrect parameter validation. ([Issue #51](https://github.com/scrthq/PSGSuite/issues/51))

## 2.6.2

* Added: `Get-GSGmailProfile` and `Get-GSDriveProfile` to pull down information for a user's Gmail or Drive account.
Expand Down
2 changes: 1 addition & 1 deletion PSGSuite/PSGSuite.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSGSuite.psm1'

# Version number of this module.
ModuleVersion = '2.6.2'
ModuleVersion = '2.6.3'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
62 changes: 37 additions & 25 deletions PSGSuite/Public/Drive/Export-GSDriveFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Export-GSDriveFile {
Exports the Drive file as a CSV to the current working directory
#>
[cmdletbinding(DefaultParameterSetName = "Depth")]
[CmdLetBinding(DefaultParameterSetName = "Depth")]
Param
(
[parameter(Mandatory = $true,Position = 0)]
Expand All @@ -66,13 +66,12 @@ function Export-GSDriveFile {
[string]
$User = $Script:PSGSuite.AdminEmail,
[parameter(Mandatory = $true)]
[ValidateSet("CSV","HTML","JPEG","JSON","MSExcel","MSPowerPoint","MSWordDoc","OpenOfficeDoc","OpenOfficeSheet","PDF","PlainText","PNG","RichText","SVG")]
[ValidateSet("CSV","EPUB","HTML","HTMLZipped","JPEG","JSON","MSExcel","MSPowerPoint","MSWordDoc","OpenOfficeDoc","OpenOfficePresentation","OpenOfficeSheet","PDF","PlainText","PNG","RichText","SVG","TSV")]
[String]
$Type,
[parameter(Mandatory = $false)]
[ValidateScript({(Get-Item $_).PSIsContainer})]
[String]
$OutFilePath = (Get-Location).Path,
$OutFilePath,
[parameter(Mandatory = $false,ParameterSetName = "Depth")]
[Alias('Depth')]
[ValidateSet("Minimal","Standard","Full","Access")]
Expand All @@ -81,7 +80,10 @@ function Export-GSDriveFile {
[parameter(Mandatory = $false,ParameterSetName = "Fields")]
[ValidateSet("appProperties","capabilities","contentHints","createdTime","description","explicitlyTrashed","fileExtension","folderColorRgb","fullFileExtension","hasThumbnail","headRevisionId","iconLink","id","imageMediaMetadata","isAppAuthorized","kind","lastModifyingUser","md5Checksum","mimeType","modifiedByMe","modifiedByMeTime","modifiedTime","name","originalFilename","ownedByMe","owners","parents","permissions","properties","quotaBytesUsed","shared","sharedWithMeTime","sharingUser","size","spaces","starred","thumbnailLink","thumbnailVersion","trashed","version","videoMediaMetadata","viewedByMe","viewedByMeTime","viewersCanCopyContent","webContentLink","webViewLink","writersCanShare")]
[String[]]
$Fields
$Fields,
[parameter(Mandatory = $false)]
[Switch]
$Force
)
Begin {
if ($Projection) {
Expand All @@ -101,20 +103,24 @@ function Export-GSDriveFile {
$fs = $Fields
}
$mimeHash = @{
CSV = "text/csv"
HTML = "text/html"
JPEG = "image/jpeg"
JSON = "application/vnd.google-apps.script+json"
MSExcel = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
MSPowerPoint = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
MSWordDoc = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
OpenOfficeDoc = "application/vnd.oasis.opendocument.text"
OpenOfficeSheet = "application/x-vnd.oasis.opendocument.spreadsheet"
PDF = "application/pdf"
PlainText = "text/plain"
PNG = "image/png"
RichText = "application/rtf"
SVG = "image/svg+xml"
CSV = "text/csv"
EPUB = "application/epub+zip"
HTML = "text/html"
HTMLZipped = "application/zip"
JPEG = "image/jpeg"
JSON = "application/vnd.google-apps.script+json"
MSExcel = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
MSPowerPoint = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
MSWordDoc = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
OpenOfficeDoc = "application/vnd.oasis.opendocument.text"
OpenOfficePresentation = "application/vnd.oasis.opendocument.presentation"
OpenOfficeSheet = "application/x-vnd.oasis.opendocument.spreadsheet"
PDF = "application/pdf"
PlainText = "text/plain"
PNG = "image/png"
RichText = "application/rtf"
SVG = "image/svg+xml"
TSV = "text/tab-separated-values"
}
if ($User -ceq 'me') {
$User = $Script:PSGSuite.AdminEmail
Expand All @@ -135,14 +141,20 @@ function Export-GSDriveFile {
if ($fs) {
$request.Fields = $($fs -join ",")
}
$res = $request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
if ($OutFilePath) {
Write-Verbose "Saving file to path '$OutFilePath'"
$stream = [System.IO.File]::Create($OutFilePath)
$request.Download($stream)
$stream.Close()
if ((Test-Path $OutFilePath) -and !$Force) {
throw "File '$OutFilePath' already exists. If you would like to overwrite it, use the -Force parameter."
}
else {
Write-Verbose "Saving file to path '$OutFilePath'"
$stream = [System.IO.File]::Create($OutFilePath)
$request.Download($stream)
$stream.Close()
}
}
else {
$request.Execute()
}
$res
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ Update-GSSheetValue Export-GSSheet

### Most recent changes

#### 2.6.3

* Fixed: `Export-GSDriveFile -OutFilePath C:\doc.pdf -Type PDF` failing due to incorrect parameter validation. ([Issue #51](https://github.com/scrthq/PSGSuite/issues/51))

#### 2.6.2

* Added: `Get-GSGmailProfile` and `Get-GSDriveProfile` to pull down information for a user's Gmail or Drive account.
Expand Down

0 comments on commit 85f4070

Please sign in to comment.