streamToS3 method
Implementation
Future<String?> streamToS3(HttpRequest request, {S3Acl acl = .private, bool autoName = true}) async {
final s3Client = App().make<S3Client>();
final config = App().make<AppConfig>();
final uuid = App().make<Uuid>();
final String fileName;
if (autoName) {
final ext = extension.isNotEmpty ? '.$extension' : '';
final uuid = Uuid().v4();
fileName = '$uuid$ext';
} else {
fileName = filename;
}
final String key = "archery/web/app-${config.get('app.id', uuid.v4())}/storage/uploads/$fileName";
if (await s3Client.putObject(
key: key,
data: await _cachedBytes, // ← Stream directly to S3
acl: acl,
contentType: contentType,
)) {
return key;
}
return null;
}