Is there any reliable way to capture file upload e

2020-06-22 01:51发布

问题:

In my content script, I want to monitor which file a is getting uploaded to a web application.

I monitor "change" event for any "input:file" element. It works on any site (such as Gmail) that uses "input:file".

However sites like imgur, use SWFUpload mechanism. I tried to capture "fileQueued" event on element that I suspected to be swfupload. But that did not work.

  • How can I capture file upload event for sites that use swfupload?
  • Are there any other plugins that manage file uploading that I would need to take care in my content script?
  • Is there any generic mechanism to tackle this problem?

(I am aware of drag-n-drop mechanism, but I have not handled that case so far. I have also read following relevant question on SO:

Grab file with chrome extension before upload)

回答1:

It's probably worth your time to experiment with the chrome.webRequest API; it appears that the onBeforeRequest event contains info about file uploads. It's a complex API with extra parameters to addListener; read the docs thoroughly.