Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify S3 Uploads Retain Cached Data, Leading to High Storage Usage #3959

Open
zamzamfp opened this issue Feb 19, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@zamzamfp
Copy link

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.
@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Feb 19, 2025
@tylerjroach
Copy link
Member

Thank you for the report. I'll go ahead and label this as a bug while we reproduce.

@tylerjroach tylerjroach added the bug Something isn't working label Feb 19, 2025
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 19, 2025
@tylerjroach tylerjroach removed the pending-triage Issue is pending triage label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants