< Back
Write-GcsObject
Post
NAME Write-GcsObject
SYNOPSIS
Replaces the contents of a Cloud Storage object.
SYNTAX
Write-GcsObject [-InputObject] <Object> [-Value <string>] [-ContentType <string>] [-ContentEncoding <string>]
[-ContentLanguage <string>] [-ContentDisposition <string>] [-CacheControl <string>] [-Metadata <Hashtable>]
[-Force <SwitchParameter>] [<CommonParameters>]
Write-GcsObject [-InputObject] <Object> -File <string> [-ContentType <string>] [-ContentEncoding <string>]
[-ContentLanguage <string>] [-ContentDisposition <string>] [-CacheControl <string>] [-Metadata <Hashtable>]
[-Force <SwitchParameter>] [<CommonParameters>]
Write-GcsObject [[-Bucket] <string>] [-ObjectName] <string> [-Value <string>] [-ContentType <string>]
[-ContentEncoding <string>] [-ContentLanguage <string>] [-ContentDisposition <string>] [-CacheControl <string>]
[-Metadata <Hashtable>] [-Force <SwitchParameter>] [<CommonParameters>]
Write-GcsObject [[-Bucket] <string>] [-ObjectName] <string> -File <string> [-ContentType <string>]
[-ContentEncoding <string>] [-ContentLanguage <string>] [-ContentDisposition <string>] [-CacheControl <string>]
[-Metadata <Hashtable>] [-Force <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
Replaces the contents of a Cloud Storage object with data from the local disk or a value from the pipeline. Use
this instead of New-GcsObject to set the contents of a Google Cloud Storage object that already exists. You will
get a warning if the object does not exist.
If this cmdlet is used when PowerShell is in a Google Cloud Storage Provider location (i.e, the shell's location
starts with gs:\\), then you may not need to supply -Bucket. For example, if the location is gs:\\my-bucket, the
cmdlet will automatically fill out -Bucket with "my-bucket". If -Bucket is still used, however, whatever value
given will override "my-bucket". If the location is inside a folder on Google Cloud Storage, then the cmdlet will
prefix the folder name to the object name.
PARAMETERS
-InputObject <Object>
The Google Cloud Storage object to write to.
Required? true
Position? 0
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Object <Object>
The Google Cloud Storage object to write to.
This is an alias of the InputObject parameter.
Required? true
Position? 0
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Bucket <string>
Name of the bucket containing the object. Will also accept a Bucket object.
Required? false
Position? 0
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ObjectName <string>
Name of the object to write to.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Value <string>
Text content to write to the Storage object. Ignored if File is specified.
Required? false
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-File <string>
Local file path to read, writing its contents into Cloud Storage.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ContentType <string>
Content type of the Cloud Storage object. e.g. "image/png" or "text/plain".
For file uploads, the type will be inferred based on the file extension, defaulting to
"application/octet-stream" if no match is found. When passing object content via the -Value parameter, the
type will default to "text/plain; charset=utf-8".
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ContentEncoding <string>
Content encoding of the Cloud Storage object. e.g. "gzip".
This metadata can be used to indcate that an object is compressed, while still maitaining the object's
underlying Content-Type. For example, a text file that is gazip compressed can have the fact that it's a text
file indicated in ContentType and the fact that it's gzip compressed indicated in ContentEncoding.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ContentLanguage <string>
Content language of the Cloud Storage object. e.g. "en".
This metadata indicates the language(s) that the object is intended for. Refer to
https://www.loc.gov/standards/iso639-2/ ... e_list.php for the supported values of this metadata.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ContentDisposition <string>
Specifies presentation information about the data being transmitted.
This metadata allows you to control presentation style of the content, for example determining whether an
attachment should be automatically displayed or whether some form of actions from the user should be required
to open it. See https://tools.ietf.org/html/rfc6266.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-CacheControl <string>
This metadata specifies two different aspects of how data is served from Cloud Storage: whether data can be
cached and whether data can be transformed.
Sets the value to "no-cache" if you do not want the object to be cached. Sets the value to
"max-age=[TIME_IN_SECONDS]" so the object can be cached up to the specified length of time. See
https://cloud.google.com/storage/docs/m ... he-control for more information.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Metadata <Hashtable>
Metadata for the Cloud Storage object. Values will be merged into the existing object. To delete a Metadata
value, provide an empty string for its value.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Force <SwitchParameter>
Force the operation to succeed, ignoring errors if no existing Storage object exists.
Required? false
Position? named
Default value False
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
Google.Apis.Storage.v1.Data.Object
The Google Cloud Storage object to write to.
System.String
Text content to write to the Storage object. Ignored if File is specified.
OUTPUTS
Google.Apis.Storage.v1.Data.Object
---------- EXAMPLE 1 ----------
PS C:\\> Get-GcsObject -Bucket "widget-co-logs" -ObjectName "status.txt" | Write-GcsObject -Value "OK"
Update the contents of the Storage Object piped from Get-GcsObject.
---------- EXAMPLE 2 ----------
PS C:\\> cd gs:\\my-bucket
PS gs:\\my-bucket> Write-GcsObject -ObjectName "log-000.txt" -Value "OK"
Updates the contents of the storage object "log-000.txt" in bucket "my-bucket".
RELATED LINKS
SYNOPSIS
Replaces the contents of a Cloud Storage object.
SYNTAX
Write-GcsObject [-InputObject] <Object> [-Value <string>] [-ContentType <string>] [-ContentEncoding <string>]
[-ContentLanguage <string>] [-ContentDisposition <string>] [-CacheControl <string>] [-Metadata <Hashtable>]
[-Force <SwitchParameter>] [<CommonParameters>]
Write-GcsObject [-InputObject] <Object> -File <string> [-ContentType <string>] [-ContentEncoding <string>]
[-ContentLanguage <string>] [-ContentDisposition <string>] [-CacheControl <string>] [-Metadata <Hashtable>]
[-Force <SwitchParameter>] [<CommonParameters>]
Write-GcsObject [[-Bucket] <string>] [-ObjectName] <string> [-Value <string>] [-ContentType <string>]
[-ContentEncoding <string>] [-ContentLanguage <string>] [-ContentDisposition <string>] [-CacheControl <string>]
[-Metadata <Hashtable>] [-Force <SwitchParameter>] [<CommonParameters>]
Write-GcsObject [[-Bucket] <string>] [-ObjectName] <string> -File <string> [-ContentType <string>]
[-ContentEncoding <string>] [-ContentLanguage <string>] [-ContentDisposition <string>] [-CacheControl <string>]
[-Metadata <Hashtable>] [-Force <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
Replaces the contents of a Cloud Storage object with data from the local disk or a value from the pipeline. Use
this instead of New-GcsObject to set the contents of a Google Cloud Storage object that already exists. You will
get a warning if the object does not exist.
If this cmdlet is used when PowerShell is in a Google Cloud Storage Provider location (i.e, the shell's location
starts with gs:\\), then you may not need to supply -Bucket. For example, if the location is gs:\\my-bucket, the
cmdlet will automatically fill out -Bucket with "my-bucket". If -Bucket is still used, however, whatever value
given will override "my-bucket". If the location is inside a folder on Google Cloud Storage, then the cmdlet will
prefix the folder name to the object name.
PARAMETERS
-InputObject <Object>
The Google Cloud Storage object to write to.
Required? true
Position? 0
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Object <Object>
The Google Cloud Storage object to write to.
This is an alias of the InputObject parameter.
Required? true
Position? 0
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Bucket <string>
Name of the bucket containing the object. Will also accept a Bucket object.
Required? false
Position? 0
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ObjectName <string>
Name of the object to write to.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Value <string>
Text content to write to the Storage object. Ignored if File is specified.
Required? false
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-File <string>
Local file path to read, writing its contents into Cloud Storage.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ContentType <string>
Content type of the Cloud Storage object. e.g. "image/png" or "text/plain".
For file uploads, the type will be inferred based on the file extension, defaulting to
"application/octet-stream" if no match is found. When passing object content via the -Value parameter, the
type will default to "text/plain; charset=utf-8".
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ContentEncoding <string>
Content encoding of the Cloud Storage object. e.g. "gzip".
This metadata can be used to indcate that an object is compressed, while still maitaining the object's
underlying Content-Type. For example, a text file that is gazip compressed can have the fact that it's a text
file indicated in ContentType and the fact that it's gzip compressed indicated in ContentEncoding.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ContentLanguage <string>
Content language of the Cloud Storage object. e.g. "en".
This metadata indicates the language(s) that the object is intended for. Refer to
https://www.loc.gov/standards/iso639-2/ ... e_list.php for the supported values of this metadata.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ContentDisposition <string>
Specifies presentation information about the data being transmitted.
This metadata allows you to control presentation style of the content, for example determining whether an
attachment should be automatically displayed or whether some form of actions from the user should be required
to open it. See https://tools.ietf.org/html/rfc6266.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-CacheControl <string>
This metadata specifies two different aspects of how data is served from Cloud Storage: whether data can be
cached and whether data can be transformed.
Sets the value to "no-cache" if you do not want the object to be cached. Sets the value to
"max-age=[TIME_IN_SECONDS]" so the object can be cached up to the specified length of time. See
https://cloud.google.com/storage/docs/m ... he-control for more information.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Metadata <Hashtable>
Metadata for the Cloud Storage object. Values will be merged into the existing object. To delete a Metadata
value, provide an empty string for its value.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Force <SwitchParameter>
Force the operation to succeed, ignoring errors if no existing Storage object exists.
Required? false
Position? named
Default value False
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
Google.Apis.Storage.v1.Data.Object
The Google Cloud Storage object to write to.
System.String
Text content to write to the Storage object. Ignored if File is specified.
OUTPUTS
Google.Apis.Storage.v1.Data.Object
---------- EXAMPLE 1 ----------
PS C:\\> Get-GcsObject -Bucket "widget-co-logs" -ObjectName "status.txt" | Write-GcsObject -Value "OK"
Update the contents of the Storage Object piped from Get-GcsObject.
---------- EXAMPLE 2 ----------
PS C:\\> cd gs:\\my-bucket
PS gs:\\my-bucket> Write-GcsObject -ObjectName "log-000.txt" -Value "OK"
Updates the contents of the storage object "log-000.txt" in bucket "my-bucket".
RELATED LINKS