Skip to content

A command-line tool for uploading files to FileBrowser server with resumable upload support using the TUS protocol.

License

Notifications You must be signed in to change notification settings

ferstar/fb-uploader

Repository files navigation

FB-Uploader

A command-line tool for uploading files to FileBrowser server with resumable upload support using the TUS protocol.

Features

  • Pure Go implementation with no third-party dependencies
  • Built-in libraries only - uses only Go standard library
  • Resumable uploads using TUS (Tus Resumable Upload Protocol)
  • Chunked upload with configurable chunk size
  • File comparison to avoid unnecessary uploads
  • Progress tracking with real-time progress display
  • Automatic sharing with configurable expiration
  • Checksum verification for upload integrity
  • Interactive mode for handling existing files
  • Silent override mode for automation
  • HTTPS/HTTP support

Installation

Binary Release (Recommended)

Download the latest binary for your platform from the releases page:

  • Linux AMD64: fb-uploader-linux-amd64
  • Linux ARM64: fb-uploader-linux-arm64
  • macOS AMD64: fb-uploader-darwin-amd64
  • macOS ARM64: fb-uploader-darwin-arm64
  • Windows AMD64: fb-uploader-windows-amd64.exe
# Example for Linux AMD64
wget https://github.com/ferstar/fb-uploader/releases/latest/download/fb-uploader-linux-amd64
chmod +x fb-uploader-linux-amd64
mv fb-uploader-linux-amd64 fb-uploader

From Source

git clone https://github.com/ferstar/fb-uploader.git
cd fb-uploader
make build

Usage

Basic Usage

./fb-uploader -host example.com -username myuser -password mypass file.txt

Using Environment Variables

export FM_HOST=example.com
export FM_USERNAME=myuser
export FM_PASSWORD=mypass
./fb-uploader file.txt

Command Line Options

  -host string
        filebrowser server host (required: use -host flag or FM_HOST env)
  -username string
        filebrowser server username (required: use -username flag or FM_USERNAME env)
  -password string
        filebrowser server password (required: use -password flag or FM_PASSWORD env)
  -chunk-size int
        chunk size in bytes (default: 10MB) (default 10485760)
  -upload-checksum
        whether to supply the Upload-Checksum header
  -print-progress
        whether to print upload progress (default true)
  -silent-override
        whether to override existing file without asking
  -use-https
        whether to use HTTPS connection (default true)

Configuration

Required Parameters

The following parameters are required and must be provided either via command line flags or environment variables:

  • Host: FileBrowser server hostname

    • Flag: -host
    • Environment: FM_HOST
  • Username: FileBrowser username

    • Flag: -username
    • Environment: FM_USERNAME
  • Password: FileBrowser password

    • Flag: -password
    • Environment: FM_PASSWORD

Optional Parameters

  • Chunk Size: Upload chunk size in bytes (default: 10MB)
  • Upload Checksum: Enable SHA1 checksum verification
  • Print Progress: Show upload progress (default: true)
  • Silent Override: Automatically override existing files
  • Use HTTPS: Use HTTPS connection (default: true)

Examples

Upload with progress display

./fb-uploader -host example.com -username myuser -password mypass largefile.zip

Silent upload (no prompts)

./fb-uploader -host example.com -username myuser -password mypass -silent-override largefile.zip

Upload with checksum verification

./fb-uploader -host example.com -username myuser -password mypass -upload-checksum file.txt

Upload with custom chunk size

./fb-uploader -host example.com -username myuser -password mypass -chunk-size 5242880 file.txt

File Handling

Existing Files

When a file already exists on the server, the tool offers several options:

  1. Compare files: Compare local and server files using SHA256 hash
  2. Resume upload: Continue from where the upload was interrupted
  3. Overwrite: Replace the existing file
  4. Skip: Skip upload and get share link for existing file

File Sharing

After successful upload, the tool automatically creates a share link with:

  • Default expiration: 8 hours
  • Direct download: Preserves original filename
  • Public access: No authentication required for download

Error Handling

The tool handles various error scenarios:

  • Network interruptions: Automatic resume from last uploaded chunk
  • Authentication failures: Clear error messages
  • File not found: Validation before upload
  • Server errors: Detailed error reporting

Development

Running Tests

go test -v

Building

go build -o fb-uploader main.go

Code Structure

  • main.go: Main application logic
  • Config: Configuration structure
  • FileBrowserClient: HTTP client for FileBrowser API
  • Uploader: TUS upload implementation

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Support

For issues and questions, please open an issue on the GitHub repository.

About

A command-line tool for uploading files to FileBrowser server with resumable upload support using the TUS protocol.

Resources

License

Stars

Watchers

Forks

Packages

No packages published