Is there any reliable way to capture file upload event in a chrome extension?

喜你入骨 提交于 2019-12-21 05:17:07

问题


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.



来源:https://stackoverflow.com/questions/20897925/is-there-any-reliable-way-to-capture-file-upload-event-in-a-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!