【问题标题】:Send a binary file to WebDav using HTTP.put in Meteor在 Meteor 中使用 HTTP.put 将二进制文件发送到 WebDav
【发布时间】:2016-05-02 19:37:46
【问题描述】:

我正在尝试处理来自http://mailin.io/doc 的电子邮件中的 base64 编码附件,并将其发送到 WebDav 服务器。目前我正在尝试执行以下操作:

HTTP.call( 'PUT', 'https://path.to.owncloud/remote.php/webdav/mail2webdav/' + currentAttachment, {
    data: Meteor.call('base64Decode',file),
    auth: "user:pass"
  }, function( error, response ) {
    if ( error ) {
      console.log( error );
    } else {
      console.log( response );
    }
  });

当我收到来自服务器的 201 返回并且 webdav 共享上的文件出现时,我无法打开它。

由于这个请求,我不确定我想要完成的事情是否可以使用 HTTP.put:https://github.com/meteor/meteor/issues/2450

有没有通用的方法?

【问题讨论】:

    标签: node.js http meteor file-upload


    【解决方案1】:

    我通过使用包streamBuffers = Npm.require("stream-buffers");解决了这个问题

    然后我在上传之前将数据放入流中

          var myReadableStreamBuffer = new streamBuffers.ReadableStreamBuffer({
              frequency: 10,   // in milliseconds.
              chunkSize: 2048  // in bytes.
          });
          
          // Parse the base64 encoded attachment to the stream end close the stream
          myReadableStreamBuffer.put(postData[item.fileName], 'base64');
          myReadableStreamBuffer.stop();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-03
      • 1970-01-01
      • 2011-05-04
      相关资源
      最近更新 更多