Storage Disks
Convert files on the application's filesystem disks, such as S3.
On this page
anydoc.disk(name)?.file(path) converts a file on one of the application's filesystem disks, and anydoc.default_disk()?.file(path) one on the default disk. The path is relative to the disk's root:
use laravel::prelude::*;
use laravel_anydoc::Anydoc;
pub async fn convert(anydoc: Inject<Anydoc>) -> laravel::Result<(String, String)> {
let stored = anydoc.disk("s3")?.file("reports/report.docx").markdown().await?;
let report = anydoc.default_disk()?.file("report.docx").markdown().await?;
Ok((stored, report))
}disk() and default_disk() fail at once when the disk is not defined in the filesystems configuration, as laravel::storage::disk and laravel::storage::default_disk do. Storage errors, such as a missing file, pass through unchanged.
Read limit
Without ANYDOC_MAX_FILE_SIZE, the file is read with Disk::get, so it is limited to the framework's 8 MiB read limit. With it, the package's limit applies instead; see Size limit.
S3 disks
The package enables no framework feature for storage. To convert files on an S3 disk, enable Laravel Rust's s3 feature in your application.
Testing
In tests, fake the disk with laravel::storage::fake and put the document on it; see Real conversions. To skip the conversion altogether, swap in a fake Anydoc.