-
Notifications
You must be signed in to change notification settings - Fork 222
Description
Describe the bug
When using Amplify to upload large files to S3, the SDK caches the file data during the upload process. While it does not pre-cache the entire file at the beginning like AWS SDK for iOS, it still retains uploaded chunks in cache without clearing them after each part is successfully uploaded.
Also, if an upload is canceled, the temporary cached data is not automatically deleted, which leads to unnecessary disk usage. Over time, this can significantly increase storage consumption on the device, particularly for large file uploads.
The code for upload
let uploadTask = Amplify.Storage.uploadFile( path: .fromString(remoteName), local: recording.url )
The code for canceling the upload
uploadTask.cancel()
Steps To Reproduce
Steps to reproduce the behavior:
1. Use Amplify S3 to upload a large file (e.g., several GBs).
2. Monitor the app’s storage usage during the upload process.
3. Observe that storage usage increases as chunks are uploaded but does not decrease as parts are sent to S3.
When canceling an ongoing upload
4. Observe that the cached data remains and does not get automatically deleted.
Expected behavior
- Uploaded chunks should be deleted after each successful part is uploaded to minimize local storage usage.
- When an upload is canceled, the SDK should automatically clean up any cached file data to free up space.
- If automatic cache management is not feasible, provide a public API method to allow developers to manually clear cache after upload completion or cancellation.
Amplify Framework Version
2.45.4
Amplify Categories
Storage
Dependency manager
Swift PM
Swift version
Swift 5
CLI version
Xcode version
16.0
Relevant log output
Is this a regression?
No
Regression additional context
No response
Platforms
iOS
OS Version
iOS 18.0
Device
iPhone 12
Specific to simulators
No response
Additional context
This issue was previously raised in the AWS iOS SDK repository (aws-sdk-ios Issue #5439).
- The recommended solution was to try Amplify, but the same problem exists here in the different format.
- There should be a mechanism to automatically clear cache after successful part uploads and allow manual cleanup in case of cancellation.