File Uploader Part 2: Server Side Save

In this episode we'll continue building the meteor-file package by adding server side methods to our custom type

Good job! That's it for "File Uploader Part 2: Server Side Save."

Need a second look? Watch again

File Uploader Part 2: Server Side Save

In this episode we'll continue building the meteor-file package by adding server side methods to our custom type. We can use npm modules on the server using the Meteor package system. This will let us use the fs and path modules from NodeJS to save a file to disk.

  • Meteor
  • Tutorial
**Related Episodes:** * <a href="http://www.eventedmind.com/posts/meteor-introducing-the-package-system" target="_blank">Introducing the Package System</a> * <a href="http://www.eventedmind.com/posts/meteor-build-a-file-upload-package" target="_blank">Build a File Upload Package</a> * <a href="https://www.eventedmind.com/feed/meteor-file-uploader-part-3-using-packages-from-github" target="_blank">File Uploader Part 3: Using Packages From GitHub</a> <p class="code-block-title">meteor-file.js</p> ```javascript if (Meteor.isServer) { var fs = Npm.require('fs'); var path = Npm.require('path'); _.extend(MeteorFile.prototype, { save: function (dirPath, options) { var filepath = path.join(dirPath, this.name); var buffer = new Buffer(this.data); fs.writeFileSync(filepath, buffer, options); } }); } ```
Join the Discussion

Want to leave a comment? .