abujehad139 / google-api-go-client

Automatically exported from code.google.com/p/google-api-go-client
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

storage: can't operate on files with spaces in the name #64

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a file with a space in the name, eg "bad file"
2. Run svc.Objects.Delete("bucket", "bad file").Do()
3. It returns `googleapi: Error 404: Not Found, notFound`

What is the expected output? What do you see instead?

Expected output is no error

What version of the product are you using? On what operating system?

Using version 116:0260180239b8

Please provide any additional information below.

The problem appears to be that in (for example)

    func (c *ObjectsDeleteCall) Do() error {

In storage/v1/storage-gen.go we find these lines

    req.URL.Path = strings.Replace(req.URL.Path, "{object}", url.QueryEscape(c.object), 1)

replacing it with this causes the Delete function to work

    req.URL.Path = strings.Replace(req.URL.Path, "{object}", strings.Replace(url.QueryEscape(c.object), "+", "%20", -1), 1)

So it appears that the storage API doesn't understand `+` in paths to mean ` ` 
but is quite willing to accept `%20`

Other methods are affected including `Get` but I haven't made a comprehensive 
survey.

I'll propose a CL in a moment for discussion as to a fix

Original issue reported on code.google.com by nic...@gmail.com on 14 Jul 2014 at 6:06

GoogleCodeExporter commented 9 years ago
CL for discussion: https://codereview.appspot.com/117760043

Original comment by nic...@gmail.com on 14 Jul 2014 at 7:53

GoogleCodeExporter commented 9 years ago
Fixed by https://codereview.appspot.com/117760043

Original comment by gmle...@google.com on 23 Jul 2014 at 6:37