serverpod_cloud_shared 0.1.1
serverpod_cloud_shared: ^0.1.1 copied to clipboard
Shared logic between Serverpod Cloud server and its clients.
import 'dart:convert';
import 'dart:io';
import 'package:serverpod_cloud_shared/serverpod_cloud_shared.dart';
// In real use, the upload description is created by the Ground Control
// server and describes where and how to upload the file.
const uploadDescription = '''
{
"type": "binary",
"httpMethod": "PUT",
"headers": {"content-type": "application/octet-stream"},
"url": "https://storage.googleapis.com/my-bucket/my-file"
}
''';
Future<void> main() async {
final data = utf8.encode('Hello, Serverpod Cloud!');
final uploader = GoogleCloudStorageUploader(uploadDescription);
final success = await uploader.upload(
Stream.fromIterable([data]),
data.length,
);
stdout.writeln(success ? 'Upload succeeded.' : 'Upload failed.');
}