| 19 | #include <string> |
| 20 | |
| 21 | void HelloWorld(std::string const& bucket_name) { |
| 22 | namespace gcs = ::google::cloud::storage; |
| 23 | auto client = gcs::Client(); |
| 24 | |
| 25 | auto const object_name = std::string{"hello-world.txt"}; |
| 26 | auto metadata = client.InsertObject(bucket_name, object_name, "Hello World!"); |
| 27 | if (!metadata) throw std::move(metadata).status(); |
| 28 | |
| 29 | auto is = client.ReadObject(bucket_name, object_name); |
| 30 | std::cout << std::string{std::istreambuf_iterator<char>{is}, {}} << "\n"; |
| 31 | if (is.bad()) throw google::cloud::Status(is.status()); |
| 32 | } |
| 33 | // [END cpp_hello_world] |
| 34 | |
| 35 | int main(int argc, char* argv[]) try { |