Tag: raspberry-pi

  • Raspberry Pi 5: File Upload Server

    At local machine

    GitHub Repository:

    https://github.com/kuanjiahong/file-upload-server

    Pull the repository into your local machine

    git clone https://github.com/kuanjiahong/file-upload-server.git

    Compile the TypeScript file to JavaScript file

    npm run build

    Transfer the built files to your Raspberry Pi 5. There are a few options to do it but I will be using the scp command

    scp -r dist/ <username>@<pi_ip_address>:<destination-path>

    And also to transfer the package.json file

    scp package.json <username>@<pi_ip_address>:<destination-path>

    At Your Raspberry Pi 5 Machine

    Install Node.js.

    refer to Raspberry Pi 5: Install Node post on how to install Node.js

    Set NODE_ENV=production

    export NODE_ENV=production

    Install node modules

    npm install --omit=dev

    Create a uploads directory

    mkdir uploads

    Start server

    node index.js

    Connecting to the server from local network:

    You can connect to the server that is running in the Raspberry Pi 5 by visiting http://[pi-ip-address]:[port-number]

    Connecting to the server from the internet:

    You will have to set up port forwarding at your router to allow remote devices from the internet to connect with your server that is hosted in your local network. It is not recommended to simply expose your home network public IP address. Make sure you read up all related resources and security concerns before exposing your server to the internet.