You do not use cnames for r2 buckets. You setup the custom domain in the R2 settings
You do not use cnames for r2 buckets. You setup the custom domain in the R2 settings
"reason":"Bad Request","statusCode":400},"message":"UnknownError". This is happening a lot




<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>InvalidArgument</Code>
<Message>Invalid Argument: Authorization</Message>
</Error>"reason":"Bad Request","statusCode":400},"message":"UnknownError"static Future<String> uploadPic(File image) async {
String fileName = DateTime.now().millisecondsSinceEpoch.toString();
const signer = AWSSigV4Signer();
final scope = AWSCredentialScope(
region: "eeur",
service: AWSService.s3,
);
const host = '{{accountid}}.r2.cloudflarestorage.com';
final serviceConfiguration = S3ServiceConfiguration();
final path = '/{{bucketname}}/$fileName.jpg';
final uploadRequest = AWSStreamedHttpRequest.put(
Uri.https(host, path),
body: image.openRead(),
headers: {
AWSHeaders.host: host,
AWSHeaders.contentType: 'image/jpg',
},
);
final signedUploadRequest = await signer.sign(
uploadRequest,
credentialScope: scope,
serviceConfiguration: serviceConfiguration,
);
final uploadResponse = await signedUploadRequest.send().response;
final uploadStatus = uploadResponse.statusCode;
if (uploadStatus == 200) {
return "{{public_link_to_image}}";
}
throw Exception("there was an error uploading the image");
}