GoogleCloudPlatform / google-cloud-powershell

PowerShell cmdlets for the Google Cloud Platform
http://googlecloudplatform.github.io/google-cloud-powershell/
Apache License 2.0
135 stars 61 forks source link

Upload a file with ObjectNamePrefix #621

Closed justlearntutors closed 5 years ago

justlearntutors commented 5 years ago

I am trying to upload a file.

WORKS New-GcsObject -Bucket "ssl-images-justlearn" -File "C:\CodeDeployWindowsDemo\EnviromentSetup\publishAppRaw\wwwroot\stylesheet.min.css"

ERROR New-GcsObject -Bucket "ssl-images-justlearn" -File "C:\CodeDeployWindowsDemo\EnviromentSetup\publishAppRaw\wwwroot\stylesheet.min.css" -ObjectNamePrefix "article"

justlearntutors commented 5 years ago

SOLUTION New-GcsObject -Bucket "ssl-images-justlearn" -File "C:\CodeDeployWindowsDemo\EnviromentSetup\publishAppRaw\wwwroot\stylesheet.min.css" -ObjectName "article\stylesheet.min.css"

justlearntutors commented 5 years ago

How do I add cache headers for file?

quoctruong commented 5 years ago

@justlearntutors, -ObjectNamePrefix and -ObjectName are actually 2 different parameters.

The -ObjectNamePrefix parameter is meant to be used with -Folder parameter. When used together, -ObjectNamePrefix is the prefix that will be applied to every object which is uploaded.

-ObjectName parameter is used for uploading a file.

quoctruong commented 5 years ago

@justlearntutors, you can use the -Metadata parameter to add metadata to the object being uploaded. For example: New-GcsObject -Bucket my-bucket "new-object" -Metadata @{"Content-Type" = "image/png"}.

You can read more about this cmdlet here