Title: Blob.metadata not preserved when uploading new file content · Issue #293 · googleapis/python-storage · GitHub
Open Graph Title: Blob.metadata not preserved when uploading new file content · Issue #293 · googleapis/python-storage
X Title: Blob.metadata not preserved when uploading new file content · Issue #293 · googleapis/python-storage
Description: blob.metadata is not preserved when uploading new file content on an existing Blob instance with blob.upload_from_string(...) unless you first reset it with blob.metadata = blob.metadata. I suspect this bug / surprising behaviour is the ...
Open Graph Description: blob.metadata is not preserved when uploading new file content on an existing Blob instance with blob.upload_from_string(...) unless you first reset it with blob.metadata = blob.metadata. I suspect...
X Description: blob.metadata is not preserved when uploading new file content on an existing Blob instance with blob.upload_from_string(...) unless you first reset it with blob.metadata = blob.metadata. I suspect...
Opengraph URL: https://github.com/googleapis/python-storage/issues/293
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Blob.metadata not preserved when uploading new file content","articleBody":"`blob.metadata` is not preserved when uploading new file content on an existing Blob instance with `blob.upload_from_string(...)` unless you first reset it with `blob.metadata = blob.metadata`.\r\n\r\nI suspect this bug / surprising behaviour is the result of the somewhat awkward mapping of the REST API onto mutable objects. It feels like setting metadata should really be a parameter of the blob upload methods instead of a mutable field on the instance.\r\n\r\n#### Environment details\r\n\r\n - OS type and version:\r\n\r\nBoth locally on my Mac and within Google Cloud Functions\r\n\r\n - Python version: `python --version`\r\n\r\nPython 3.8.5\r\n\r\n - pip version: `pip --version`\r\n\r\npip 20.1.1\r\n\r\n - `google-cloud-storage` version: `pip show google-cloud-storage`\r\n\r\ngoogle-cloud-storage==1.31.2\r\n\r\n#### Steps to reproduce\r\n\r\n See code example.\r\n\r\n#### Code example\r\n\r\n```python\r\n\u003e\u003e\u003e b = bucket.blob('testme1')\r\n\u003e\u003e\u003e b.metadata = {'test': 'me'}\r\n\u003e\u003e\u003e b.upload_from_string('foo')\r\n\u003e\u003e\u003e b.metadata\r\n{'test': 'me'}\r\n\u003e\u003e\u003e b.upload_from_string('bar')\r\n\u003e\u003e\u003e b.metadata\r\n\u003e\u003e\u003e # Note how b.metadata is not blank\r\n\r\n\u003e\u003e\u003e b = bucket.blob('testme2')\r\n\u003e\u003e\u003e b.metadata = {'test': 'me'}\r\n\u003e\u003e\u003e b.upload_from_string('foo')\r\n\u003e\u003e\u003e b.metadata\r\n{'test': 'me'}\r\n\u003e\u003e\u003e b.metadata = b.metadata # \u003c-- workaround\r\n\u003e\u003e\u003e b.upload_from_string('bar')\r\n\u003e\u003e\u003e b.metadata\r\n{'test': 'me'}\r\n\u003e\u003e\u003e # Note how b.metadata is now preserved\r\n```\r\n","author":{"url":"https://github.com/lrowe","@type":"Person","name":"lrowe"},"datePublished":"2020-10-13T23:14:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/293/python-storage/issues/293"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c6ce6fb8-3e93-24af-d780-05cc2bc6b6ca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 88A0:16BCD3:162EF6E:1EBC19B:6A4EACBF |
| html-safe-nonce | 481d270c6459bea0673959aa44be948bf378108886780c270a7b93f80c456a0c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OEEwOjE2QkNEMzoxNjJFRjZFOjFFQkMxOUI6NkE0RUFDQkYiLCJ2aXNpdG9yX2lkIjoiMTY5NTUwMzc4NDI5NjIzMDA3OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ee2790aa904081c287a76f8a0f3fa487bcc49d8b4f0207e38b0856ac4559fa36 |
| hovercard-subject-tag | issue:720970963 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-storage/293/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a30c64dc01c4aa1032b504593758f7d48a5612abe2042d6fdbddd120fd5737b2/googleapis/python-storage/issues/293 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a30c64dc01c4aa1032b504593758f7d48a5612abe2042d6fdbddd120fd5737b2/googleapis/python-storage/issues/293 |
| og:image:alt | blob.metadata is not preserved when uploading new file content on an existing Blob instance with blob.upload_from_string(...) unless you first reset it with blob.metadata = blob.metadata. I suspect... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lrowe |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-storage git https://github.com/googleapis/python-storage.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992639 |
| octolytics-dimension-repository_nwo | googleapis/python-storage |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992639 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-storage |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e6a744804e8e70f97b4d5a18a94dcc63db22f97a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width