upload method Null safety

  1. @override
Future<bool> upload()

Implementation

@override
Future<bool> upload() async {
  //Upload the file to the cloud.
  //The file path is contained in the UploadTask config.

  AWSSigV4Signer client = AWSSigV4Signer(
      region: config.credentailsConfig.region,
      accessKey: config.credentailsConfig.accessKey,
      secretKey: config.credentailsConfig.secretKey,
      hostEndpoint: config.credentailsConfig.host);

  File file = config.file!;

  List<int> fileByte = await file.readAsBytes();

  final datetime = Utils.generateDatetime();

  final authorizationHeader = client.buildAuthorizationHeader(
      'PUT', '/${config.url}', {}, Utils.trimString(datetime),
      unSignedPayload: true, bytesPayload: fileByte);

  var header = client.headers;
  header['Authorization'] = authorizationHeader;

  //Now upload the file
  final bool uploadSuccessful = await fileUploader(
      onSendProgress: (count, total) {
        _uploadProgress.add([count, total]);
      },
      bytesPayload: fileByte,
      onSendComplete: onSendComplete,
      headers: header,
      url: 'https://${config.credentailsConfig.host}/${config.url}');

  return uploadSuccessful;
}