File Operations
Download PDF Document
DownloadValidateMedium
Description
Download a PDF file and verify its size, Content-Disposition header, and basic PDF structure.
Test Scenario
// Playwright: Download and verify PDF
const response = await request.get('/api/v1/files/download?format=pdf');
expect(response.headers()['content-type']).toBe('application/pdf');
expect(response.headers()['content-disposition']).toContain('report.pdf');
// Get binary content
const buffer = await response.body();
expect(buffer.length).toBeGreaterThan(0);
// Check PDF magic bytes
const header = buffer.slice(0, 5).toString();
expect(header).toBe('%PDF-');Endpoint
/api/v1/files/download?format=pdf&rows=10Testing Tips
- •Check Content-Type is application/pdf
- •Verify PDF magic bytes (%PDF-)
- •Check Content-Length header
- •For full PDF parsing, use pdf-parse library
// Playwright API Testing - File Operationsimport { test, expect } from '@playwright/test';test('File download', async ({ request }) => {const response = await request.get('/api/files/download/report.pdf');expect(response.ok()).toBeTruthy();expect(response.headers()['content-type']).toContain('application/pdf');const buffer = await response.body();expect(buffer.length).toBeGreaterThan(0);});
Challenge ID: download-pdf
2 frameworks available
API Playground
Send requests and inspect responses
Endpoint: /api/v1/files/download?format=pdf&rows=10
Press Enter to send