Skip to content

Kodifly/tus-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TUS Implementation

This repository demonstrates an implementation of the TUS protocol for resumable file uploads. The TUS protocol is a standard for resumable uploads, allowing clients to upload files to a server in a fault-tolerant and efficient manner. It supports pausing, resuming, and retrying uploads, making it ideal for large file transfers.


Repository Structure

  • client/: Contains the client-side implementation for uploading files using the TUS protocol.
  • server/: Contains the server-side implementation for handling TUS uploads and processing files.

Installation

Prerequisites

  • Node.js (v16 or later)
  • npm (Node Package Manager)

Steps

  1. Clone the repository:

    git clone https://github.com/Kodifly/tus-implementation.git
    cd tus-implementation
  2. Install dependencies for the client:

    cd client
    npm install
  3. Install dependencies for the server:

    cd ../server
    npm install

Usage

Client

  1. Configure the .env file in the client/ directory:

    FOLDER_PATH=/path/to/your/folder
    HOST=localhost
    PORT=8000
    
  2. Start the client:

    cd client
    npm start
  3. The client will upload all the files present in the FOLDER_PATH environment variable to the server.


Server

  1. Configure the .env file in the server/ directory:

    HOST=localhost
    PORT=8000
    UPLOAD_PATH=../uploads
    PROCESSED_PATH=../processed
    API_TOKEN=your-api-token
    
  2. Start the server:

    cd server
    npm start
  3. The server will listen for incoming TUS uploads and process them.


🔌 Endpoints

Server Endpoints

POST /upload/files

  • Description: Creates a new upload session.
  • Headers:
    • Upload-Length: Total size of the file in bytes
    • Upload-Metadata: Metadata about the file (e.g., filename)
  • Response:
    • 201 Created: Returns the upload URL in the Location header.

POST /api/videos/api-token-segmentation

  • Description: Processes uploaded videos.
  • Body:
    {
      "api_token": "your-api-token",
      "file_uuids": ["uuid1", "uuid2"]
    }
  • Using CURL
    curl -X POST http://10.12.12.13:8000/api/videos/api-token-segmentation \
    -H "Content-Type: application/json" \
    -d '{
       "api_token": "your-api-token",
       "file_uuids": ["uuid1","uuid2"]
    }'
  • Note: Replace 10.12.12.13 and 8000 with the actual server IP and Port number.
  • Response:
    • 200 OK: Returns the task ID for the processing job.

Example Workflow

  1. Start the server.
  2. Use the client to upload a file.
  3. Use CURL to call the /api/videos/api-token-segmentation to process the uploaded file.
  4. Download the processed file using /api/download/{file_uuid}.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published