File Share Web Software – Entry #1

This week I started writing a file sharing software for the web. I wanted to start creating Entry posts, to track progress and issues I’m having.

note: I’m going to post some code below, but it’s not all the steps required to get up and running

I’m building it in Rust using the actix framework with diesel for interacting with the DB on the backend.

And on the frontend I’m just planning on using something fast. Probably Vue.js with Bulma CSS.

I started off by initializing the project with Rust’s cargo, and then bringing in the packages I knew I needed:

Next, I started writing the file. I need to get the API running, so I initialized a “server” via the actix-web readme.

extern crate actix_web;
use actix_web::{server, App, HttpRequest, Responder};

fn greet(req: &HttpRequest) -> impl Responder {
    let to = req.match_info().get("name").unwrap_or("World");
    format!("Hello {}!", to)

fn main() {
    server::new(|| {
            .resource("/", |r| r.f(greet))
            .resource("/{name}", |r| r.f(greet))
    .expect("Can not bind to port 8000")

Now that that was running, I know I needed a database. I’m preferential to PostgreSQL, so I created a docker compose file to get that running.

version: '3.1'

    image: postgres:latest
    restart: always
      - 5432:5432
      POSTGRES_PASSWORD: postgres

note: I opted to use a compose file because I’m more familiar with them and I imagine I might add another service down the line

Then, I started structuring the data for the SQL table. The files aren’t actually going to be stored in the DB. I’m probably going to use Digital Ocean’s spaces for that. I do want the SQL rows to have some data for displaying on the frontend. Spaces can handle the actual downloads.

CREATE TABLE file_links (
  storage_location TEXT NOT NULL,
  title TEXT,
  description TEXT,
  downloads INTEGER DEFAULT 0

And that’s as far as I got for now. My next steps that I want to take are these: