Quickstart

Get started with FileLens file preview generation in minutes. This guide will walk you through generating your first preview and understanding the core concepts.

Installation

FileLens can be deployed using Docker, which is the recommended approach for both development and production environments.

Using Docker Compose (Recommended)

# Clone the repository
git clone <repository-url>
cd filelens

# Start the service
docker-compose up -d

# Check if it's running
curl http://localhost:3000/health

Using Docker

# Build and run the container
docker build -t filelens:latest .
docker run -d -p 3000:3000 --name filelens filelens:latest

The service will be available at http://localhost:3000.


Generate Your First Preview

Once FileLens is running, you can generate your first preview using a simple HTTP request.

Basic Example

curl -X POST http://localhost:3000/preview \
  -H "Content-Type: application/json" \
  -d '{
    "input": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "output_format": "jpg"
  }'

Response

{
  "success": true,
  "message": "Preview generated successfully",
  "preview_urls": [
    "/download/sync_1641312000_12345_def4_1.jpg"
  ],
  "total_pages": 1,
  "job_id": null
}

Download the Preview

curl -X GET http://localhost:3000/download/sync_1641312000_12345_def4_1.jpg \
  -o preview.jpg
# cURL is most likely already installed on your machine
curl --version

Making your first API request

After setting up your development environment, you are ready to make your first call to the FileLens API. Below, you can see how to send a POST request to the preview endpoint to generate a file preview.

POST
/preview
curl -X POST http://localhost:3000/preview \
  -H "Content-Type: application/json" \
  -d '{
    "input": "https://example.com/document.pdf",
    "output_format": "jpg",
    "options": {
      "width": 800,
      "height": 600,
      "quality": 90,
      "all_pages": true
    }
  }'

Understanding the response

A successful request will return a JSON response with download URLs for the generated previews:

{
  "success": true,
  "message": "Preview generated successfully",
  "preview_urls": [
    "/download/sync_1641312000_12345_def4_1.jpg",
    "/download/sync_1641312000_12345_def4_2.jpg",
    "/download/sync_1641312000_12345_def4_3.jpg"
  ],
  "total_pages": 3,
  "job_id": null
}

You can then download the preview files using the provided URLs:

curl http://localhost:3000/download/sync_1641312000_12345_def4_1.jpg -o preview_page_1.jpg

What's next?

Great, you're now set up and have made your first request to the FileLens API. Here are a few links that might be handy as you venture further: