I create a s3 presigned URL in typescript as below:
const params = {
Bucket: myBucketName,
Key: uuidv4(),
Expires: 3600,
};
s3.getSignedUrlPromise('putObject', params)
and I used below code in flutter to upload image to this url:
Option1:
var formData = FormData.fromMap({
"file":
await MultipartFile.fromFile(image.path, filename: "upload.png"),
});
var response = await Dio().put(url, data: formData);
Option2:
return Dio().put(
url,
data: image.openRead(),
options: Options(
contentType: "multiple/form-data",
headers: {
"Content-Length": image].lengthSync(),
},
),
onSendProgress: (int sentBytes, int totalBytes) {
double progressPercent = sentBytes / totalBytes * 100;
print("upload $progressPercent %");
},
)
in both cases I got 403 forbidden error response. How can I upload images to the presigned URL? Is there anything wrong in the generated side or flutter side?
I can upload the file with curl command like below:
curl -XPOST -H "Content-Type: application/x-www-form-urlencoded" --data-binary "@/Users/Pictures/IMG_4634.jpg" $PRESIGNED_URL
so the url does work.