BookStackApp/BookStack · error · ZipExportException
errors.import_zip_data_too_large
Error message
errors.import_zip_data_too_large
What it means
ZipExportReader::readData() throws 'errors.import_zip_data_too_large' when the uncompressed size of the embedded data.json exceeds the application's configured upload limit (config('app.upload_limit') in megabytes, minimum 1). BookStack refuses to decode oversized import payloads to protect memory. This happens before json_decode runs.
Source
Thrown at app/Exports/ZipExports/ZipExportReader.php:68
$this->open = false;
}
}
/**
* @throws ZipExportException
*/
public function readData(): array
{
$this->open();
$info = $this->zip->statName('data.json');
if ($info === false) {
throw new ZipExportException(trans('errors.import_zip_cant_decode_data'));
}
$maxSize = max(intval(config()->get('app.upload_limit')), 1) * 1000000;
if ($info['size'] > $maxSize) {
throw new ZipExportException(trans('errors.import_zip_data_too_large'));
}
// Validate json data exists, including metadata
$jsonData = $this->zip->getFromName('data.json') ?: '';
$importData = json_decode($jsonData, true);
if (!$importData) {
throw new ZipExportException(trans('errors.import_zip_cant_decode_data'));
}
return $importData;
}
public function fileExists(string $fileName): bool
{
return $this->zip->statName("files/{$fileName}") !== false;
}
public function fileWithinSizeLimit(string $fileName): boolView on GitHub (pinned to 18f8469a1c)
Solutions
- Raise 'upload_limit' in config/app.php (or APP_UPLOAD_LIMIT env) to exceed the data.json size in MB, then clear config caches (php artisan config:clear).
- Split the export into smaller books/chapters on the source instance.
- Confirm with `unzip -l export.zip` how large data.json is and set the limit accordingly.
- If the limit won't budge, import content manually via the API instead.
Example fix
// before (.env) APP_UPLOAD_LIMIT=10 // after APP_UPLOAD_LIMIT=200
Defensive patterns
Strategy: validation
Validate before calling
$zip = new ZipArchive();
$zip->open($path);
$stat = $zip->statName('data.json');
$limitMb = max((int) config('app.upload_limit'), 1);
if ($stat !== false && $stat['size'] > $limitMb * 1000000) {
throw new \RuntimeException("data.json is {$stat['size']} bytes; exceeds {$limitMb}MB upload limit");
} Try / catch
try {
$model = $reader->decodeDataToExportModel();
} catch (\BookStack\Exports\ZipExports\ZipExportException $e) {
report($e); // surface which limit was hit
// raise APP_UPLOAD_LIMIT or split the export
} Prevention
- Check data.json size with unzip -l before importing.
- Set APP_UPLOAD_LIMIT generously on instances that import large exports.
- Run php artisan config:clear after changing the limit.
- Split very large books into smaller exports.
When it happens
Trigger: Importing a BookStack ZIP export whose data.json 'size' from statName() is greater than max(app.upload_limit,1) * 1000000 bytes — i.e. large exports with many pages/attachments metadata.
Common situations: Very large book/chapter exports from a big instance; app.upload_limit left at default (e.g. 10 or unset/0) while the export is larger; PHP memory limits also being tight on shared hosting.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- File $fileName exceeds app upload limit.
- errors.import_zip_cant_decode_data
- Could not identify content in ZIP file data.
- errors.import_validation_failed
- Must not have a parent set for a Book import.
AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02).
Data as JSON: /api/errors/3354c0613315fad6.
Report an issue: GitHub.