I'm trying to make a browser extension that takes input from a user in the pop-up bar and then uploads it to S3 using AWS-Amplify Storage.put(). Currently the upload process is happening from within the pop-up.
The problem is that if during the upload is in progress, user clicks outside the pop-up - it closes and on re-opening the state is lost and there is no way of tracking the put request. Now I obviously store the state in background but the issue is I cannot use AWS amplify APIs from the background script. On researching I was able to find the following alternatives -
- Injecting a content script in a tab and then uploading from there.
My problem with this approach is that what if the user terminates the tab which is uploading? Overall this approach seems very hacky.
- Opening a new tab/window for upload and asking the user explicitly to not close it before upload succeeds.
Can anyone please suggest a better approach? I'm new to browser extensions and have been following the documentation for firefox extensions (MDN).
Thanks