google_cloud_storage 0.6.2 copy "google_cloud_storage: ^0.6.2" to clipboard
google_cloud_storage: ^0.6.2 copied to clipboard

A client for Google Cloud Storage, a managed service for storing, archiving, and serving unstructured data of any size.

example/main.dart

// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// #docregion main
import 'package:google_cloud_storage/google_cloud_storage.dart';

void main() async {
  // By default, the `Storage` class will use the currently configured project
  // and automatically attempt to authenticate using Application Default
  // Credentials.
  final storage = Storage();

  // Create a bucket.
  final bucket = await storage.createBucket(
    BucketMetadata(
      name: 'put-your-bucket-name-here',
      defaultObjectAcl: [
        ObjectAccessControl(entity: 'allUsers', role: 'READER'),
      ],
    ),
  );
  await storage.uploadObjectFromString(
    bucket.name!,
    'index.html',
    '<h1>Hello World!</h1>',
    metadata: ObjectMetadata(contentType: 'text/html'),
  );
  print(
    'Your website is available at:\n'
    'https://storage.googleapis.com/${bucket.name}/index.html',
  );
  storage.close();
}

// #enddocregion main
5
likes
160
points
3.74k
downloads

Documentation

API reference

Publisher

verified publisherlabs.dart.dev

Weekly Downloads

A client for Google Cloud Storage, a managed service for storing, archiving, and serving unstructured data of any size.

Repository (GitHub)
View/report issues
Contributing

License

Apache-2.0 (license)

Dependencies

clock, collection, convert, crypto, ffi, google_cloud, google_cloud_protobuf, google_cloud_rpc, googleapis_auth, http, meta

More

Packages that depend on google_cloud_storage