CulturalMe / meteor-slingshot

Upload files directly to AWS S3, Google Cloud Storage and others in meteor
MIT License
595 stars 104 forks source link

How to make the upload conditional ? #234

Open sbdm05 opened 6 years ago

sbdm05 commented 6 years ago

Hello, I have a form with multiple fields: how can I validate the form even without a image ? Right now, it throws "not a file", and the form is not saved unless I add an image (even if I edit the form).

  handleSubmit(e, props) {
    e.preventDefault();
upload.send(document.getElementById("uploadFile").files[0], function(
      error,
      downloadUrl
    ) {
      uploader.set();

      if (error) {
        alert(error);
      } else {
      console.log("Success!");
      console.log("uploaded file available here: " + downloadUrl);

      Meteor.call(
        "laws.update",
        lawId,
        titleLoi,
        abstractLoi,
        downloadUrl
      );
      }
      uploader.set(upload);
    });