Work with files on the client side (javascript / jQuery) before / after upload / download

I just figure it out, looking around a bit and drawing a space. I would like to see if this is possible until I see a way to do this.

I want to encrypt a file locally (in a browser using existing libraries) before downloading it. Then I will need to restore and decrypt it before presenting the file to the user. In particular, I cannot send the file to the server for encryption before storage. Encryption / decryption must be done on the client side.

Here is a rough flow of what I need to do:

  • Present the file widget to the user.
  • Read the client side script file (i.e. upload it locally)
  • Encrypt it on the client.
  • Download the encrypted version, clear the client part and save the data.

And vice versa:

  1. Download the saved, encrypted version of the file.
  2. Decrypt it on the client.
  3. Present the decrypted file back to the user as a download.

I was looking for some kind of MIME encoding on the client (similar to how email attachments are encoded MIME before sending in plain text). I'm particularly interested in the jQuery method, like what the rest of my application uses, but plain old javascript will be fine.

Any thoughts or pointers are greatly appreciated. This is the one I reflect on the holidays. So, well in advance for any comments.

+2
javascript jquery mime file-upload
source share
4 answers

It is not possible to do this using plain Javascript or jQuery due to browser security restrictions.

Best of all, if you use an open source Flash-based download component, such as SWFUpload (Flash can be much larger or client-side) and adding encryption procedures to ActionScript. The correct options for creating a Java applet or ActiveX control are also available.

Depending on what kind of encryption we are talking about, there may also be ready-made components for work.

+4
source share

You cannot do this using JavaScript. You can, of course, just use SSL (for example, via HTTPS). Dead is easy, well tested, all this. Otherwise, you will have to use something non-standard, such as Flash, Java or ActiveX.

+3
source share

The accepted answer is deprecated here. This can be done using the HTML5 API files and something like the CryptoJS library .

+1
source share

I cannot talk with other browsers , but I know that it should be possible in Firefox by manipulating api files to upload / download files from the user to the client code (where they can be processed) and standard ajax to upload / download files from client code to the server.

0
source share

All Articles