By Jerome Jumah
I am trying to upload files in my flutter application using dospace and I have been getting this error message : flutter: DOException { statusCode: 403, reasonPhrase: “Forbidden”, responseBody: “<?xml version=“1.0” encoding=“UTF-8”?><Error><Code>InvalidAccessKeyId</Code><RequestId>tx0000000000000245603d7-0063457665-5c963c72-fra1b</RequestId><HostId>5c963c72-fra1b-fra1-zg02</HostId></Error>” }
Future<void> uploadFileMethod() async {
dospace.Spaces spaces = dospace.Spaces(
//change with your project's region
region: "fra1",
//change with your project's accessKey
accessKey: "*************",
//change with your project's secretKey
secretKey: "*****************************",
endpointUrl: 'https://fra1.digitaloceanspaces.com',
);
try {
var pickedFile;
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
File file = File(result.files.single.path as String);
pickedFile = file;
} else {
// User canceled the picker
return;
}
String projectName = "*******"; // change to projectname
// change with your project's region
String region = "fra1";
// change with your project's folder
String folderName = "videofiles";
String fileName = pickedFile.path.split('/').last;
String? etag = await spaces.bucket(projectName).uploadFile(
"$folderName/$fileName",
pickedFile,
"image/jpg",
dospace.Permissions.public,
);
print(etag);
await spaces.close();
} catch (error) {
print(error);
}
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello @jeromejumah
The first step will be to verify that the AccessKey is correct. You can also try to generate a new pair of secret and access key.
I’ve had a similar issue in the past but also my string for the endpoint was embedded two times and thus making the URL incorrect.
Regards
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.