< Back

Add-GDriveItem

Mon Jan 13, 2020 10:21 pm

NAME Add-GDriveItem



SYNOPSIS

Creates new GoogleDrive Item, set metadata and upload content





SYNTAX

Add-GDriveItem -StringContent <String> [-Encoding <Encoding>] [-JsonProperty <String>] [-ContentType <String>]

[-ChunkSize <Int32>] [-ShowProgress] -AccessToken <String> [-WhatIf] [-Confirm] [<CommonParameters>]



Add-GDriveItem -StringContent <String> [-Encoding <Encoding>] -Name <String> [-ParentID <String[]>] [-ContentType

<String>] [-ChunkSize <Int32>] [-ShowProgress] -AccessToken <String> [-WhatIf] [-Confirm] [<CommonParameters>]



Add-GDriveItem -RawContent <Byte[]> [-JsonProperty <String>] [-ContentType <String>] [-ChunkSize <Int32>]

[-ShowProgress] -AccessToken <String> [-WhatIf] [-Confirm] [<CommonParameters>]



Add-GDriveItem -RawContent <Byte[]> -Name <String> [-ParentID <String[]>] [-ContentType <String>] [-ChunkSize

<Int32>] [-ShowProgress] -AccessToken <String> [-WhatIf] [-Confirm] [<CommonParameters>]



Add-GDriveItem -InFile <String> [-JsonProperty <String>] [-ContentType <String>] [-ChunkSize <Int32>]

[-ShowProgress] -AccessToken <String> [-WhatIf] [-Confirm] [<CommonParameters>]



Add-GDriveItem -InFile <String> -Name <String> [-ParentID <String[]>] [-ContentType <String>] [-ChunkSize <Int32>]

[-ShowProgress] -AccessToken <String> [-WhatIf] [-Confirm] [<CommonParameters>]





DESCRIPTION

Creates new GoogleDrive Item, set metadata and upload content





PARAMETERS

-StringContent <String>

Content to upload as string



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Encoding <Encoding>

Enconding used for string



Required? false

Position? named

Default value [System.Text.Encoding]::UTF8

Accept pipeline input? false

Accept wildcard characters? false



-RawContent <Byte[]>

Content to upload as raw byte[] array



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-InFile <String>

Content to upload as path to file



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Name <String>

Name of an item to be created



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ParentID <String[]>

Folder ID in which new item will be placed



Required? false

Position? named

Default value @('root')

Accept pipeline input? false

Accept wildcard characters? false



-JsonProperty <String>

Json-formatted string with all needed file metadata



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ContentType <String>

Uploaded item Content type (seems google automatically set it to most of uploaded files)



Required? false

Position? named

Default value application/octet-stream

Accept pipeline input? false

Accept wildcard characters? false



-ChunkSize <Int32>

Upload request size



Required? false

Position? named

Default value 4194304

Accept pipeline input? false

Accept wildcard characters? false



-ShowProgress [<SwitchParameter>]

Show progress bar while uploading



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-AccessToken <String>

Access Token for request



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Confirm [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

PSObject with properties:

Item: Json with item metadata as PSObject

ResultID: Upload ID for resume operations

Error: Error info if happen





NOTES





Author: Max Kozlov



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>#Named File based upload



Add-GDriveItem -AccessToken $access_token -InFile D:\\SomeDocument.doc -Name SomeDocument.doc









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>#Named Raw data upload with ParentID



[byte[]]$Content = Get-Content D:\\SomeDocument.doc -Encoding Bytes

$ParentFolder = Find-GDriveItem -AccessToken $access_token -Query 'name="myparentfolder"'

Add-GDriveItem -AccessToken $access_token -RawContent -Name SomeDocument.doc -ParentID $ParentFolder.files.id









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>#String based upload with metadata



Add-GDriveItem -AccessToken $access_token -StringContent 'test file' -JsonProperty '{ "name":"myfile.txt" }'











RELATED LINKS

Set-GDriveItemProperty

Set-GDriveItemContent