5

I want to do background upload of files which does not impact the primary usage of the page once the upload of files has started being processed.

In addition to this we want to be able to navigate away from the page performing the upload to other pages in the application without interrupting the upload.

I have implemented it using Web worker/SharedWorker to send file object to server using XMLHTTPRequest post request in background. It works fine while upload is initiated and no navigation to other page. but on navigating to page2.html after starting the upload from page1.html, request.getPart() returns null on server side and upload fails.

Does task submitted using sharedWorker stops/halts on navigation to other page in same domain ?

Why does request.getPart() return null on navigating to other page since sharedWorker must still be running on navigating to other page in same domain ?

Structure of my application is:

  1. main.html - has multipart form and creates sharedworker thread to upload form
  2. worker.js - sends file object to server using XMLHTTPRequest post request.
  3. server - HTTP servlet processes the post request and saves the file

How can we achieve following functionality :

  • initiate an upload from main page using background SharedWorker/WebWorker
  • navigate to other page2 in same domain
  • navigate back to main page and get status of upload from SharedWorker/WebWorker

Any links/suggestions will be highly appreciable.

Thanks, Manpreet

0 Answers0