Sails.js checking stuff before uploading files to MongoDB with skipper (valid files, image resizing etc)

前端 未结 2 921
南笙
南笙 2020-12-17 04:29

I\'m currently creating a file upload system in my application. My backend is Sails.js (10.4), which serves as an API for my separate front-end (Angular).

I\'ve cho

2条回答
  •  温柔的废话
    2020-12-17 05:21

    You can specify a callback for the .upload() function. Example:

    req.file('media').upload(function (error, files) {
      var file;
    
      // Make sure upload succeeded.
      if (error) {
        return res.serverError('upload_failed', error);
      }
    
      // files is an array of files with the properties you want, like files[0].size
    }
    

    You can call the adapter, with the file to upload from there, within the callback of .upload().

提交回复
热议问题