上传/下载之前/之后的客户端(JavaScript / jQuery)文件操作 [英] Client side (javascript/jQuery) file manipulation before/after upload/download

查看:133
本文介绍了上传/下载之前/之后的客户端(JavaScript / jQuery)文件操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是听到这个问题,看了一会儿,画了一个空白。我想看看这是甚至可能的,因为目前为止我看不到一种方法来做到这一点。

我想在本地加密一个文件(在浏览器使用现有的库)上传之前。然后我需要检索它并解密它,然后将文件呈现给用户。具体而言,我不能将文件发送到服务器进行加密之前存储。加密/解密需要执行客户端。



以下是我需要做的粗略流程:


  1. 为用户提供查找文件小部件。
  2. 将文件读入客户端脚本(即,在本地加载)

  3. 在客户机上加密它。


  4. $ b $上传加密版本,刷新客户端并存储数据。 b

    然后反过来:


    1. 下载存储的加密版本的文件。

    2. 在客户端解密它。

    3. 将解密后的文件作为下载呈现给用户。
      $ b

      我一直在客户端寻找某种MIME编码(类似于电子邮件附件在以纯文本形式发送之前进行MIME编码的方式)。我特别感兴趣的是一个jQuery方法,因为这是我的应用程序的其余部分正在使用,但普通的旧javascript将罚款。



      任何想法或指针非常感激接收。这是我正在考虑假期的人。所以,在此先感谢您的任何意见。

      解决方案

      由于安全限制,无法使用纯Javascript或JQuery来执行此操作在浏览器中。

      最好的办法可能是采用基于Flash的开源组件, > SWFUpload (Flash可以更多,或客户端),并在ActionScript中添加加密例程。创建Java小程序或ActiveX控件也是有效的选项。



      根据我们所谈论的加密类型,也可能有现成的组件。


      I'm just sounding things out about this having looked around for a while and drawn a blank. I'd like to see if this is even possible as so far I can't see a way to do it.

      I want to encrypt a file locally (in the browser using existing libraries) before uploading it. Then I'll need to retrieve it and decrypt it before presenting the file to the user. Specifically, I can't send the file to the server for encryption before storage. Encryption/decryption needs to be performed client side.

      Here's a rough flow of what I need to do:

      1. Present user with a find-file widget.
      2. Read file into client side script (i.e. load it locally)
      3. Encrypt it on the client.
      4. Upload encrypted version, flush the client side and store the data.

      And, in reverse:

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

      I've been looking for some kind of MIME encoding on the client (similar to the way email attachments are MIME encoded before being sent as plain text). I'm particularly interested in a jQuery method, as that's what the rest of my app is using, but plain old javascript would be fine.

      Any thoughts or pointers very gratefully received. This is the one I'm mulling over the holidays. So, thanks in advance for any comments.

      解决方案

      There is no way to do this using plain Javascript or JQuery due to security restrictions in the browser.

      Your best bet is probably taking a open source Flash based upload component like SWFUpload (Flash can much more or the client side) and adding the encryption routines there in ActionScript. Creating a Java applet or an ActiveX control are also valid options.

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

      这篇关于上传/下载之前/之后的客户端(JavaScript / jQuery)文件操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆