aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.33k stars 247 forks source link

SqliteException(6922): disk I/O error Occurs During Amplify Storage File Upload in Flutter App #5571

Open bjmcallister opened 1 month ago

bjmcallister commented 1 month ago

Description

I'm experiencing a SqliteException(6922): disk I/O error when attempting to upload a video file using Amplify.Storage.uploadFile in my Flutter application. This error arises specifically during an INSERT operation into the transfer_records table within the SQLite database. The issue prevents successful uploads and disrupts the user experience.

Steps to Reproduce Ensure the Flutter environment is correctly set up with all necessary dependencies. Amplify is properly configured for storage in the Flutter app.

Code Execution Trigger the upload process, which involves generating a UUID, checking file existence, creating an AWSFile instance, and invoking Amplify.Storage.uploadFile.

Error Trigger During the execution of the uploadFile method, the app attempts to insert a new record into the transfer_records table. The SqliteException(6922): disk I/O error is thrown at this point. Expected Behavior The video file should upload successfully to AWS Amplify Storage, and a corresponding record should be inserted into the transfer_records SQLite table without any errors.

Actual Behavior An exception is thrown during the upload process, preventing the insertion of a new record into the transfer_records table and halting the upload operation.

SqliteException(6922): while executing statement, disk I/O error, disk I/O error (code 6922) Causing statement: INSERT INTO "transfer_records" ("upload_id", "object_key", "created_at") VALUES (?, ?, ?), parameters: IGn7zlX4vYK00bsxjMlTdd.UMaskDNIG21RylQ9ac6vA0vP4HBK8f71puCH0.PakERK7pymwvWbLEOkvLcuoPkkcqH2OUKwq987TmPDLewhbPDSvFrjwJRw2VseCzN6YMzZSdQp3JJeq1zVGJ9ZUi_FoTYurhFNFaEdbUvrTRx8-, videos/46c572e2-70d4-41de-b612-a5a82e952cce.mp4, 2024-10-18T11:40:47.705803 Reloaded 1 of 3917 libraries in 1,212ms (compile: 169 ms, reload: 501 ms, reassemble: 498 ms).

final uuid = Uuid();
final String keyName = uuid.v4();

final file = File(pendingUpload.path);
if (!await file.exists()) {
  throw Exception(
      'File does not exist at path: ${pendingUpload.path}');
}

// Create an AWSFile instance after confirming the file exists
final awsFile = AWSFile.fromPath(pendingUpload.path);

// Use a dynamic storage path to avoid conflicts
final result = Amplify.Storage.uploadFile(
  localFile: awsFile,
  path: StoragePath.fromString('videos/$keyName.mp4'),
  options: const StorageUploadFileOptions(
    metadata: {
      'project': 'salesmail',
    },
  ),
).result;

await result;

Categories

Steps to Reproduce

Ensure the Flutter environment is correctly set up with all necessary dependencies. Amplify is properly configured for storage in the Flutter app.

Screenshots

No response

Platforms

Flutter Version

3.24.3

Amplify Flutter Version

2.1.0 & 2.4.0

Deployment Method

Amplify Gen 2

Schema

No response

bjmcallister commented 1 month ago

https://github.com/user-attachments/assets/b37f12f0-b7b8-4d84-b213-9b86db318baa

https://github.com/user-attachments/assets/306dd7df-d28a-45b6-90e6-3da2844ee61a

Two videos. The longer one does not work while the shorter one does.

NikaHsn commented 1 month ago

Sorry that you are facing this issue. We will look into this and get back to you when we have updates.