ds_storage_gcp 0.0.1
ds_storage_gcp: ^0.0.1 copied to clipboard
Google Cloud Storage provider for DartStream.
DartStream GCS Storage Provider #
Google Cloud Storage provider for DartStream using the official googleapis client.
Install #
dependencies:
ds_storage_base: ^0.0.1
ds_storage_gcp: ^0.0.1
Usage #
import 'package:ds_storage_base/ds_storage_base_export.dart';
import 'package:ds_storage_gcp/ds_storage_gcp_export.dart';
final config = {
'name': 'gcs',
'bucket': 'my-gcs-bucket',
'serviceAccountPath': '/path/to/service-account.json',
};
registerGcpStorageProvider(config);
final storage = DSStorageManager('gcs');
await storage.initialize(config);
await storage.uploadFile('avatars/user.png', bytes);
final signed = await storage.getSignedUrl('avatars/user.png');
Configuration #
bucket(optional if you passbucket/objectpaths)serviceAccountPathorserviceAccount(required)scopes(optional)publicUrl/baseUrl(optional)name(optional, defaultgcs)
Notes #
- Signed URLs use an OAuth access token and expire with the token lifetime.
- If no default bucket is configured, pass
bucket/objectas the path.