< Back

Set-GDriveItemContent

Mon Jan 13, 2020 10:29 pm

NAME Set-GDriveItemContent



SYNOPSIS

Creates or updates GoogleDrive Item, set metadata and upload content





SYNTAX

Set-GDriveItemContent [[-ID] <String>] -InFile <String> [-JsonProperty <String>] [-ResumeID <String>]

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

[<CommonParameters>]



Set-GDriveItemContent [[-ID] <String>] -StringContent <String> [-Encoding <Encoding>] [-JsonProperty <String>]

[-ResumeID <String>] [-ContentType <String>] [-ChunkSize <Int32>] [-ShowProgress] -AccessToken <String> [-WhatIf]

[-Confirm] [<CommonParameters>]



Set-GDriveItemContent [[-ID] <String>] -RawContent <Byte[]> [-JsonProperty <String>] [-ResumeID <String>]

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

[<CommonParameters>]



Set-GDriveItemContent -StringContent <String> [-Encoding <Encoding>] -Name <String> [-ParentID <String[]>]

[-ResumeID <String>] [-ContentType <String>] [-ChunkSize <Int32>] [-ShowProgress] -AccessToken <String> [-WhatIf]

[-Confirm] [<CommonParameters>]



Set-GDriveItemContent -RawContent <Byte[]> -Name <String> [-ParentID <String[]>] [-ResumeID <String>]

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

[<CommonParameters>]



Set-GDriveItemContent -InFile <String> -Name <String> [-ParentID <String[]>] [-ResumeID <String>] [-ContentType

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





DESCRIPTION

Creates or updates GoogleDrive Item, set metadata and upload content

If needed tp update existing file, use ID

If only metadata update required, use Set-GDriveItemProperty





PARAMETERS

-ID <String>

File ID to update



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-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(s) 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



-ResumeID <String>

Upload ID to resume operations in case of uploading errors



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



Set-GDriveItemContent -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"'

Set-GDriveItemContent -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" }'









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>#String based update upload



Set-GDriveItemContent -AccessToken $access_token -ID '0BAjkl4cBDNVpVbB5nGhKQ195aU0' -StringContent 'test file'









-------------------------- EXAMPLE 5 --------------------------



PS C:\\>#File based resume operation



$Result = Set-GDriveItemContent -AccessToken $access_token -InFile D:\\SomeDocument.doc -Name SomeDocument.doc

if ($Result.Error) {

Set-GDriveItemContent -AccessToken $access_token -InFile D:\\SomeDocument.doc `

-Name SomeDocument.doc -ResumeID $Result.ResumeID

}











RELATED LINKS

Add-GDriveItem

Set-GDriveItemProperty

https://developers.google.com/drive/api ... les/create

https://developers.google.com/drive/api ... les/update

https://developers.google.com/drive/api ... ble-upload