Related Resources

Our Services

You May Also Like

How to upload file using BusBoy in combination with ExpressJS, NodeJS and TypeScript?

Krunal Shah

Aug 18, 2017

3 min readLast Updated Dec 12, 2022

upload file using BusBoy in combination with ExpressJS, NodeJS and TypeScript

We believe adaptation to the latest trends in the coding. Hence, we have been using TypeScript in all our major projects. We love code the the frontend in Angular 2, React and the dynamic backend in NodeJS.

Here’s a small example we have created using TypeScript, NodeJS and ExpressJS to upload a file with BusBoy using Typescript.

Please follow the below steps.

Step 1: Clone repository with the following command.

git clone

https://github.com/thirdrocktechkno/trt-express-nodejs-typescript-busboy-fileupload-emaple.git

Step 2: Go to project directory and run

npm install

Step 3: Now execute. ( npm run grunt command is for compiling the typescript

source code, you can check out gruntfile.js have all the configuration. )

npm run grunt

Step 4: Create images folder inside the dist folder

mkdir dist/images

Step 5: Now run

npm run start
[http://localhost:8080/](http://localhost:8080/)

Step 7: Here is the URL for file upload

http://localhost:8080/fileupload and pass multipart form data.

Brief information about Typescript files.

  1. server.ts in src folder -> In this file we export the Server class, this class will configure our express web application, REST API and routes.
  2. route.ts in src/routes/ folder -> This file will export the BaseRoute class, In this class you can define script for all routes which will be required. Method render() will invoke BaseRoute’s child class.
  3. index.ts in src/routes/ folder -> This class extends BaseRoute class, you can define route in create() method.
  4. routes() method in server.ts -> In this method we have created router instance of express.Router() and call the create() method of IndexRoute and passed router as a parameter.

I hope the steps have got the example running in you local machine. We love to share at Third Rock Techkno what we learn with our community.

Happy coding !!!

Do share your feedback. :)

TRT

We are a team of expert developers, testers and business consultants who strive to deliver nothing but the best. Planning to build a completely secure and efficient Node app? 'Hire Node JS Developer'.

· · · ·

Third Rock Techkno is a leading IT services company. We are a top-ranked web, voice and mobile app development company with over 10 years of experience. Client success forms the core of our value system.

We have expertise in the latest technologies including angular, react native, iOs, Android and more. Third Rock Techkno has developed smart, scalable and innovative solutions for clients across a host of industries.

Our team of dedicated developers combine their knowledge and skills to develop and deliver web and mobile apps that boost business and increase output for our clients.

Projects Completed till now.

Discover how we can help your business grow.

"Third Rock Techkno's work integrates complex frameworks and features to offer everything researchers need. They are open-minded and worked smoothly with the academic subject matter."

- Dr Daniel T. Michaels, NINS