javascript - edgee:slingshot error [Invalid directive] -


so have been trying add edgee:slingshot meteor + react project reason keep getting same error: "error: directive myfileuploads not seem exist [invalid directive]"

i have followed tutorial implement information can't seem figure out what's wrong code.

any highly appreciated.

my upload-rules file:

slingshot.filerestrictions("myfileuploads", {    allowedfiletypes: ["image/png", "image/jpeg", "image/gif"],    maxsize: 10 * 1024 * 1024 // 10 mb (use null unlimited)  });    slingshot.createdirective("myfileuploads", slingshot.s3storage, {    bucket:                "ec2016",     region:                 "eu-central-1",    acl:                    "public-read",      authorize: function () {      //deny uploads if user not logged in.      if (!this.userid) {        var message = "please login before posting files";        throw new meteor.error("login required", message);      }        return true;    },      key: function (file) {      //store file directory user's username.      var user = meteor.users.findone(this.userid);      return user.username + "/" + file.name;    }  });

my form:

export default class addspark extends component {    constructor(props) {      super(props);        this.upload = this.upload.bind(this)    }      createspark(event){      event.preventdefault();      const spark = {        city: this.city.value,        person: this.person.value,        location: this.location.value,        title: this.title.value,        content: this.content.value,        url: this.url.value,      }      console.log(spark);    }      componentwillmount(){      // create rule both on client , server      slingshot.filerestrictions("myfileuploads", {        allowedfiletypes: ["image/png", "image/jpeg", "image/gif"],        maxsize: 10 * 1024 * 1024 // 10 mb (use null unlimited)      });    }        upload(){      var uploader = new slingshot.upload("myfileuploads");        uploader.send(document.getelementbyid('input').files[0], function (error, downloadurl) {        if (error) {          // log service detailed response          alert (error);        }        else {          meteor.users.update(meteor.userid(), {$push: {"profile.files": downloadurl}});        }      });    }      render() {      return (        <div>          <form  ref={(input) => this.sparkform = input} onsubmit={(e) => this.createspark(e)}>                <controllabel>select city</controllabel>              <select id="formcontrolscity" placeholder="choose city" classname="form-control" onclick={ moreoptions } ref={(input) => this.city = input}>                <option value="select">choose city</option>                <option value="beijing">beijing</option>                <option value="shanghai">shanghai</option>                <option value="chengdu & chongqing">chengdu & chongqing</option>              </select>                       <controllabel>select person</controllabel>              <select id="formcontrolsperson" placeholder="choose person" classname="form-control" ref={(input) => this.person = input}>                <option value="select">first select city</option>              </select>                      <controllabel>select location</controllabel>              <select id="formcontrolslocation" placeholder="choose location" classname="form-control" ref={(input) => this.location = input}>                <option value="select">first select city</option>              </select>                <controllabel>title</controllabel>              <input type="text" label="title" placeholder="enter title" classname="form-control" ref={(input) => this.title = input}/>                            <controllabel>content</controllabel>              <textarea placeholder="enter comment here" classname="form-control" ref={(input) => this.content = input}/>              <div classname="upload-area">                <p classname="alert alert-success text-center">                  <span>click or drag image here upload</span>                  <input type="file" id="input" ref={(input) => this.url = input} onchange={this.upload} />                </p>            </div>              <button type="submit">submit</button>          </form>        </div>    )}  }

beside ofcourse have setting.json file store s3 keys.

have great day , don't forget smile.

i managed fix this. eventhough thought upload-rules.js in server folder. turned out not in right one. after moving right folder works.

so has same problem, double check if file in right place.


Comments

Popular posts from this blog

c# SetCompatibleTextRenderingDefault must be called before the first -

c++ - Fill runtime data at compile time with templates -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -