PreviewFile IconPreviewFile.dev

API 개요

간단한 REST API로 프로그래밍 방식으로 보안 파일 미리보기 링크를 생성합니다.

빠른 시작

PreviewFile.dev는 URL에서 미리보기 링크를 생성하는 간단한 REST API를 제공합니다. 단일 API 호출로 보안되고 시간 제한이 있는 미리보기 링크를 생성하세요.

110+ 지원 파일 형식: PDF, Office 문서, 이미지, 비디오, 코드 파일 등을 미리보기. 전체 목록은 지원 형식을 참조하세요.

POST /api/u

URL에서 미리보기 링크 생성:

curl -X POST https://previewfile.dev/api/u \
  -H "Content-Type: application/json" \
  -H "x-api-key: $API_KEY" \
  -d '{
    "url": "https://example.com/document.pdf",
    "ttlMinutes": 120,
    "watermark": "Confidential",
    "noDownload": true,
    "oneTime": false
  }'

응답:

{
  "success": true,
  "data": {
    "shortUrl": "a1b2c3d4",
    "previewUrl": "https://previewfile.dev/p/a1b2c3d4",
    "expireAt": "2025-10-02T15:30:00Z",
    "status": "READY",
    "ttlMinutes": 120,
    "watermark": "Confidential",
    "noDownload": true,
    "oneTime": false
  }
}

API는 보안과 가독성을 위해 nanoid(8)로 짧은 링크를 자동 생성합니다.

API 참조

인증

x-api-key 헤더에 API 키 포함:

x-api-key: YOUR_API_KEY

Stable OpenAPI (/api/v1)

For long-term integration, prefer the versioned API surface:

  • OpenAPI schema: GET /api/v1/openapi.json
  • Upload file (multipart): POST /api/v1/upload
  • Get preview metadata: GET /api/v1/previews/{shortUrl}
  • Get file access URL (direct or S3 presigned): GET /api/v1/previews/{shortUrl}/file-url

Upload example

curl -X POST https://previewfile.dev/api/v1/upload \
  -H "x-api-key: $API_KEY" \
  -F "file=@./document.pdf" \
  -F "ttlMinutes=60" \
  -F "watermark=Confidential" \
  -F "noDownload=true" \
  -F "oneTime=false"

Fetch file access URL

curl -X GET https://previewfile.dev/api/v1/previews/a1b2c3d4/file-url \
  -H "x-api-key: $API_KEY"

요청 매개변수

필드타입필수기본값설명
urlstring예-미리보기할 원본 URL
ttlMinutesnumber아니오60링크 유효성(분) (5-1440)
watermarkstring아니오null워터마크 텍스트 (최대 120자)
noDownloadboolean아니오false다운로드 기능 비활성화
oneTimeboolean아니오false첫 번째 보기 후 만료

응답

성공 응답 (200):

{
  "success": true,
  "data": {
    "shortUrl": "a1b2c3d4",
    "previewUrl": "https://previewfile.dev/p/a1b2c3d4",
    "expireAt": "2025-10-02T15:30:00Z",
    "status": "READY",
    "ttlMinutes": 120,
    "watermark": "Confidential",
    "noDownload": true,
    "oneTime": false
  }
}

응답 필드:

필드타입설명
shortUrlstring8자리 짧은 URL 식별자
previewUrlstring공유할 전체 미리보기 URL
expireAtstringISO 8601 만료 타임스탬프
statusstring미리보기 상태: READY, PENDING 또는 EXPIRED
ttlMinutesnumber링크 유효성 기간
watermarkstring | null구성된 경우 워터마크 텍스트
noDownloadboolean다운로드 제한 상태
oneTimeboolean일회성 액세스 제한

오류 응답 (4xx/5xx):

{
  "success": false,
  "error": "오류 메시지"
}

사용 예제

cURL

curl -X POST https://previewfile.dev/api/u \
  -H "Content-Type: application/json" \
  -H "x-api-key: $API_KEY" \
  -d '{
    "url": "https://example.com/document.pdf",
    "ttlMinutes": 120,
    "watermark": "Confidential",
    "noDownload": true,
    "oneTime": false
  }'

Node.js (Fetch)

const response = await fetch('https://previewfile.dev/api/u', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    url: 'https://example.com/document.pdf',
    ttlMinutes: 120,
    watermark: 'Confidential',
    noDownload: true,
    oneTime: false
  })
});

const data = await response.json();
console.log(data.data.previewUrl);

Python (Requests)

import requests

response = requests.post(
    'https://previewfile.dev/api/u',
    headers={
        'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
    },
    json={
        'url': 'https://example.com/document.pdf',
        'ttlMinutes': 120,
        'watermark': 'Confidential',
        'noDownload': True,
        'oneTime': False
    }
)

data = response.json()
print(data['data']['previewUrl'])

기능

  • 110+ 파일 형식: PDF, Office 문서, 이미지, 비디오, 코드 등의 네이티브 브라우저 미리보기 (전체 목록 참조)
  • 짧은 URL: 보안을 위해 nanoid로 자동 생성되는 8자리 식별자
  • 시간 제한: 5분에서 24시간까지 만료 설정
  • 워터마크: 미리보기에 사용자 정의 텍스트 오버레이 추가
  • 다운로드 제어: 파일 다운로드를 선택적으로 비활성화
  • 일회성 링크: 첫 번째 액세스 후 링크 만료
  • 원본 URL 숨김: 수신자는 원본 파일 URL을 볼 수 없음
  • 클라이언트 사이드 렌더링: 모든 미리보기 엔진이 브라우저에서 실행되어 최대 보안 제공

On this page