0

The difficulty comes from the fact that chrome extensions can only make external http requests through the background.js file which is separate from the extension and all communication between the two are serialized, which removes files.

I've found some solutions from 1++ years ago, but all seem to be very hacky and not working anymore anyway (as tends to happen to hacky solutions).

So I am left wondering if it is possible at all to upload files from a chrome extension that opens on any website.

coiso
  • 7,151
  • 12
  • 44
  • 63
  • Why do you think you can not make requests form a content script? – Makyen Feb 23 '17 at 19:14
  • The difficulty @Makyen is passing the files to the content script, where the request can be made – coiso Feb 23 '17 at 19:42
  • Then your question is unclear. Please [edit] the question to state *exactly* what you are trying to do. Be specific. For example, "make external http requests" should tell us *exactly* which methods you are using. – Makyen Feb 23 '17 at 19:49
  • 1
    Possible duplicate of [Chrome extension: how to pass ArrayBuffer or Blob from content script to the background without losing its type?](http://stackoverflow.com/questions/8593896/chrome-extension-how-to-pass-arraybuffer-or-blob-from-content-script-to-the-bac) – Daniel Herr Feb 23 '17 at 21:19

1 Answers1

2

If memory serves, I am fairly sure I am making external web requests from a content script in a Chrome extension.

However, if we just consider how to get a file into the background thread, the following options jump to mind, depending on your needs.

  1. chrome.storage can be used to access local storage
  2. chrome.fileSystem can be used to access the host file system
  3. File content could be suitably encoded (say base64) and sent across with chrome.runtime.sendMessage in the JSON message. (I am not sure if there is a message size constraint. I suppose it could be sent in pieces if there were.)
user650881
  • 2,214
  • 19
  • 31