amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

Error : amplify upload file function not throwing an exception

Open lavishmanghnani2 opened this issue 6 months ago • 7 comments

Description

I'm encountering an issue while using the amplify_storage_s3 package in a Flutter application. The issue occurs under the following circumstances:

When we upload larger files on S3 and suddenly the internet goes down or OFF

Expected Behavior:

The upload file function throw any exception

my code :

  Future<void> uploadIOFile(
      {required File file,
      required int index,
      required String name,
      required S3UploadFileOperation? uploadOperation,
      required BuildContext? context,
      required Function(StorageTransferProgress progress)
          returnProgress}) async {
    try {
      final storagePlugin = Amplify.Storage.getPlugin(
        AmplifyStorageS3.pluginKey,
      );
      final awsFile = AWSFilePlatform.fromFile(file);

      uploadOperation = storagePlugin.uploadFile(
          localFile: awsFile,
          options: const StorageUploadFileOptions(
            pluginOptions: S3UploadFilePluginOptions(
              useAccelerateEndpoint: true,
            ),
          ),
          key: name,
          onProgress: (StorageTransferProgress progress) {
            uploaderLastTime = DateTime.now();
            //  print("MeeeWorkkingforat>>>>>>>>>>$index");
            manageOperationWithState(uploadOperation: uploadOperation);
            returnProgress(progress);
          });
      await uploadOperation.result.catchError((e) {
        throw Exception(e);
      });
    } on StorageException catch (e) {
      //   safePrint('Error uploading file: ${e.message}');
      throw Exception(e);
    } catch (e) {
      throw Exception(e);
    }
  }

When the internet goes off in the middle of uploading the response I'm getting :

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DELETE https://dental-drive122415-dev.s3.us-east-1.amazonaws.com/public/65e160509d8ba938a5368b88/9B77E407-F085-4A35-BE1B-A09F1494F7BE/1723805881801/C%3A/New%20folder%20%283%29/android-studio-2024.1.1.12-windows%20-%20Copy.exe?x-id=AbortMultipartUpload&uploadId=3nopqwZnhVwAhf2JnCM09BJxbzwG3xVizYXocZNUs0NRHQbGNNf9VZGflRGMesaDUeB80883u02S1AurOtUSa02le9Ljsp736Zne2UcUy6xUWUc7R2.0d6o5ug8E.qO4mZhMkQUENJDJb_AOzUJP6cIoA7bxmDUinaE7ybgmPFA- failed: SocketException: Failed host lookup: 'dental-drive122415-dev.s3.us-east-1.amazonaws.com' (OS Error: No such host is known.

, errno = 11001)

Categories

  • [ ] Analytics
  • [ ] API (REST)
  • [ ] API (GraphQL)
  • [ ] Auth
  • [ ] Authenticator
  • [ ] DataStore
  • [ ] Notifications (Push)
  • [X] Storage

Steps to Reproduce

  1. Set up a Flutter application using these packages amplify_storage_s3: ^1.8.0 amplify_flutter: ^1.8.0 amplify_auth_cognito: ^1.8.0 aws_common: ^0.6.5, packages.

  2. Upload larger files more then 500 MB

  3. Turn off the pc internet from settings

Screenshots

No response

Platforms

  • [ ] iOS
  • [ ] Android
  • [ ] Web
  • [ ] macOS
  • [X] Windows
  • [ ] Linux

Flutter Version

">=3.3.0 <4.0.0"

Amplify Flutter Version

amplify_storage_s3: ^1.8.0 amplify_flutter: ^1.8.0 amplify_auth_cognito: ^1.8.0 aws_common: ^0.6.5

Deployment Method

Amplify CLI

Schema

No response

lavishmanghnani2 avatar Aug 16 '24 11:08 lavishmanghnani2