Skip to content

Amplify.Storage does not invoke "resultListener" block while Application is in Background #1762

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

Closed
chintan1891 opened this issue Apr 23, 2022 · 4 comments
Assignees
Labels
storage Issues related to the Storage category

Comments

@chintan1891
Copy link

Describe the bug

I have implemented "Amplify.Storage.uploadFile" for File upload. But if my app goes in background, then my "resultListener" block is not getting called.

Steps To Reproduce

Steps to reproduce the behavior:
1. Implement "Amplify.Storage.uploadFile"
2. Start File Uploading
3. Put Application in Background
4. Check S3 Console, File is not being uploaded there

Expected behavior

File should get uploaded in background

Amplify Framework Version

1.23.0

Amplify Categories

Storage

Dependency manager

Cocoapods

Swift version

5

CLI version

Xcode version

13.3.1

Relevant log output

No response

Is this a regression?

No

Regression additional context

No response

Device

iPhone 7

iOS Version

15.4

Specific to simulators

No response

Additional context

No response

@thisisabhash thisisabhash added storage Issues related to the Storage category pending-triage Issue is pending triage labels Apr 26, 2022
@ameter
Copy link
Contributor

ameter commented May 6, 2022

Hi @chintan1891, can you share a snippet of the code you're using to perform the upload? Also, does the upload work correctly when the app remains in the foreground?

@chintan1891
Copy link
Author

chintan1891 commented May 9, 2022

Yes, Upload works perfectly fine while app is in foreground.
Here is the code snippet:

let uploadOperation = Amplify.Storage.uploadFile(
    key: key,
    local: fileURL,
    progressListener: { progress in
        Logger.log("Progress: \(progress) %")
    }, resultListener: { event in
        self.semaphore.signal()
        switch event {
        case let .success(data):
            Logger.log("File \(filename) uploaded: \(data)")
        case let .failure(storageError):
            Logger.log("Failed to upload file \(filename): \(storageError.errorDescription). \(storageError.recoverySuggestion)")
        }
    }
)

@harsh62 harsh62 self-assigned this May 13, 2022
@chintan1891
Copy link
Author

@harsh62 any update on this?

@harsh62
Copy link
Member

harsh62 commented Jun 17, 2022

@chintan1891 Amplify Storage doesn't currently support background transfers. You might need to take a look at Transfer Utility documentation. Also linking background transfers documentation if you want to look at managing background transfers.

We are tracking support for background operations in Amplify.Storage in #1102

@harsh62 harsh62 added closing soon This issue will be closed in 7 days unless further comments are made. and removed pending-triage Issue is pending triage labels Jun 17, 2022
@harsh62 harsh62 closed this as completed Jun 23, 2022
@github-actions github-actions bot removed the closing soon This issue will be closed in 7 days unless further comments are made. label Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
storage Issues related to the Storage category
Projects
None yet
Development

No branches or pull requests

4 participants