write method
Implementation
@override
Future<void> write(
String key,
List<int> bytes, {
required String contentType,
required String cacheControl,
}) async {
final tmpDir = await Directory.systemTemp.createTemp('hotpatch-upload-');
try {
final tmp = File(p.join(tmpDir.path, 'blob'));
await tmp.writeAsBytes(bytes, flush: true);
final result = await Process.run(aws, [
's3',
'cp',
tmp.path,
_url(key),
'--content-type',
contentType,
'--cache-control',
cacheControl,
'--only-show-errors',
]);
if (result.exitCode != 0) {
throw CliException(
'Upload to ${_url(key)} failed: ${'${result.stderr}'.trim()}',
);
}
} finally {
await tmpDir.delete(recursive: true);
}
}