new setmeta command throws error when setting Cache-Control

135 views
Skip to first unread message

Eric James Soltys

unread,
Aug 13, 2012, 2:07:32 PM8/13/12
to gsutil-...@googlegroups.com
The new setmeta command (Thanks!) has trouble with key:value pairs containing commas...

gsutil setmeta '"Cache-Control:public, max-age=3600"' gs://bucket/object

...raises this error...

CommandException: Fields being added must include values ( max-age=3600').

I tried a few variations without luck.

Eric

Mike Schwartz (Google Storage Team)

unread,
Aug 13, 2012, 2:17:26 PM8/13/12
to gsutil-...@googlegroups.com
Hi Eric,

That error message indicates the argument got split into multiple args before it was passed to gsutil. Are you possibly running gsutil from a wrapper script? If so perhaps that wrapper script isn't preserving the arg boundaries.

I just tried running the command you tried, and it worked for me.

Mike

Eric James Soltys

unread,
Aug 13, 2012, 4:46:26 PM8/13/12
to gsutil-...@googlegroups.com, gs-...@google.com
Hi Mike,

No, I was testing commands directly from the Windows 7 command prompt (including PowerShell), so it must be an OS quirk.

I use Ubuntu for coding, but I use gsutil as part of my image workflow under Windows. I'll launch an Ubuntu session and see if I have the same problem.

Eric

Eric James Soltys

unread,
Aug 13, 2012, 5:15:02 PM8/13/12
to gsutil-...@googlegroups.com, gs-...@google.com
I can confirm it's a Windows-related problem. I was able to use setmeta without problems under Ubuntu.

[sigh]

Mike Schwartz (Google Storage Team)

unread,
Aug 13, 2012, 5:36:32 PM8/13/12
to gsutil-...@googlegroups.com
Hi Eric,

Yes, this problem comes about because of differences in how Linux/MacOS and Windows do command line parsing (of which I was previously unaware). The following syntax (though not pretty) should work around the problem on Windows:

gsutil setmeta """Cache-Control:public, max-age=3600""" gs://bucket/object

More generally, you need two sets of double quotes around each header/value pair, and one set of double quotes around the entire expression. For example, to set two headers you would do:

gsutil setmeta """Cache-Control:public, max-age=3600"",""Content-Type:text/html""" gs://bucket/object

Please give it a try and let me know if it works for you on Windows. I'll update the built-in documentation.

Thanks,

Mike

Eric James Soltys

unread,
Aug 13, 2012, 6:02:35 PM8/13/12
to gsutil-...@googlegroups.com, gs-...@google.com
Hi Mike,

The extra pairs of double-quotes solves the parsing problem from the Windows command-line.

Thanks,

Eric

Google Storage Team

unread,
Aug 13, 2012, 6:06:34 PM8/13/12
to Eric James Soltys, gsutil-...@googlegroups.com
Thanks For checking, Eric.

Mike


Original Message Follows:
------------------------
From: Eric James Soltys <eso...@gmail.com>
Subject: Re: new setmeta command throws error when setting Cache-Control
Date: Mon, 13 Aug 2012 15:02:35 -0700 (PDT)
<eso...@gmail.com<javascript:>
Reply all
Reply to author
Forward
0 new messages