I am using the pdf 3.6.0
library from pub.dev to generate a pdf in flutter web. When I save the document using doc.save()
, I get a Future<Uint8List>
. I want to upload this file to S3
For android/ios, I first save the Uint8List
as a file in a temp directory, using path_provider
and then use file.openRead()
to get data to upload to S3 and it works perfectly.
I am unable to replicate the same process in flutter web since dart:io
is unavailable for flutter web. Even universal_io
does not help.
I did try to directly push the uint8list
to s3 using the below code
await dio.put(
s3PresignedURLForPUT,
data: uint8listData,
options: Options(
contentType: "application/pdf",
headers: {
"Content-Length": length,
},
),
onSendProgress: (int sentBytes, int totalBytes) {
double progressPercent = sentBytes / totalBytes * 100;
print("$progressPercent %");
},
);
But when I open this file again in S3 I get an error saying: "Failed to load PDF document."
How can achieve the same result for the pdf generated for flutter web?