{"action":"opened","issue":{"url":"https://api.github.com/repos/kurin/blazer/issues/14","repository_url":"https://api.github.com/repos/kurin/blazer","labels_url":"https://api.github.com/repos/kurin/blazer/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/kurin/blazer/issues/14/comments","events_url":"https://api.github.com/repos/kurin/blazer/issues/14/events","html_url":"https://github.com/kurin/blazer/issues/14","id":234127935,"number":14,"title":"An easy way to check if file exists in backblaze","user":{"login":"kjk","id":7935,"avatar_url":"https://avatars2.githubusercontent.com/u/7935?v=3","gravatar_id":"","url":"https://api.github.com/users/kjk","html_url":"https://github.com/kjk","followers_url":"https://api.github.com/users/kjk/followers","following_url":"https://api.github.com/users/kjk/following{/other_user}","gists_url":"https://api.github.com/users/kjk/gists{/gist_id}","starred_url":"https://api.github.com/users/kjk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjk/subscriptions","organizations_url":"https://api.github.com/users/kjk/orgs","repos_url":"https://api.github.com/users/kjk/repos","events_url":"https://api.github.com/users/kjk/events{/privacy}","received_events_url":"https://api.github.com/users/kjk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-07T08:16:58Z","updated_at":"2017-06-07T08:16:58Z","closed_at":null,"body":"I can't figure out how to (easily) find out if file already exists.\r\n\r\nI tried:\r\n```go\r\nfunc BackblazeExists(b2Path string) (bool, error) {\r\n\tctx := context.Background()\r\n\tbucket, err := getBucket(ctx)\r\n\tif err != nil {\r\n\t\treturn false, err\r\n\t}\r\n\r\n\tobj := bucket.Object(b2Path)\r\n\t_, err = obj.Attrs(ctx)\r\n\tif err == nil {\r\n\t\treturn true, nil\r\n\t}\r\n\tif b2.IsNotExist(err) {\r\n\t\treturn false, nil\r\n\t}\r\n\treturn false, err\r\n}\r\n```\r\nBut the error from obj.Attrs() is `b2_download_file_by_name: 404: bucket kjkpub does not have file:` and doesn't match `b2.IsNotExist()`.\r\n\r\nI can think of few (unsatisfactory) work-arounds, given the current api:\r\n* I could assume that every error from obj.Attrs() means \"doesn't exit\", but that's not entirely correct.\r\n* I could match the error text for \"does not have file\" but that seems hacky.\r\n* I could use ListCurrentObjects().\r\n\r\nPossible solutions in the library:\r\n* expose `Bucket.getObject` as `Bucket.getObject` so that I don't have to use `Object.Attrs()`\r\n* have `Object.Attrs()` return an error with `notFoundErr = true` for the case of \"object doesn't exist\"\r\n"}}
{"actor":{"display_login":"kjk"}}