使用Meteor的Filestack删除文件安全性错误

时间:2018-02-04 02:43:46

标签: reactjs meteor filestack

我试图让react filestack插件与meteor一起使用,当我打开安全设置时我遇到了麻烦,因此我可以删除我上传的文件。我需要使用App Secret, policy, signature, apikey来删除文件。我收到错误Error: security policy and signature are required to remove,我收到另一个错误,要求App Secret。知道我做错了什么。

路径:ImageUpload.jsx

import React from 'react';
import PropTypes from 'prop-types';
import ReactFilestack from 'filestack-react';

export default class ImageUpload extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};

    this.handleImageUpload = this.handleImageUpload.bind(this);
    this.handleDelete = this.handleDelete.bind(this);
  }

  handleImageUpload(result) {
    console.log('Image upload worked');
  }

  handleDelete() {
    console.log("Remove image worked");
  }

  render() {
    const options = {
      fromSources: ["local_file_system","webcam","facebook","instagram","dropbox"],
      accept: 'image/*',
      maxFiles: 1,
      transformations: { crop: { force: false } },
      storeTo: {
        location: 's3',
      },

    };

    const security = {
      policy: 'mypolicykey',
      signature: 'mysignuture',
      handle: 'imagehandle'
    };

    return (
      <div>
        <ReactFilestack
          apikey={'myapikey'}
          buttonText="Upload image"
          buttonClass="btn btn-secondary"
          options={options}
          onSuccess={this.handleImageUpload}
          security={security}
        />

        <ReactFilestack
          apikey={'myapikey'}
          buttonText="Delete image"
          buttonClass="btn btn-secondary"
          options={security}
          onSuccess={this.handleDelete}
          mode={'remove'}
        />
      </div>
    );
  }
}

路径:settings-dev

{
  "public": {
    "filepicker":{
      "secret": "mysecertapp",
      "policy": "mypolicy",
      "signature": "mysignature"
    }
  },
  "private": {
  },
}

1 个答案:

答案 0 :(得分:1)

在您删除的地方,您没有通过安全或签名:

    <ReactFilestack
      apikey={'myapikey'}
      buttonText="Delete image"
      buttonClass="btn btn-secondary"
      options={security}
      onSuccess={this.handleDelete}
      mode={'remove'}
    />

事实上,你有options={security},我确定这是错误的