1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Keep the files your application stores, such as uploads and generated reports, on your server
//! or in S3-compatible storage.
//!
//! Files live on named disks from `config.filesystems`. The functions in this module use the
//! default disk, which `FILESYSTEM_DISK` names, and [`disk`] picks another disk by name. A [`Disk`]
//! reads and writes files, streams them to other disks, and serves them as
//! [downloads](Disk::download) or through [URLs](Disk::url). To learn how to configure disks,
//! store uploads, and test file storage, check out the
//! [file storage guide](https://github.com/laravel/rust-framework/blob/0.x/docs/filesystem.md).
//!
//! ```no_run
//! # async fn example() -> laravel::Result<()> {
//! use laravel::storage;
//!
//! let invoices = storage::disk("local")?;
//! invoices.put("invoices/paid.txt", "Paid").await?;
//! assert_eq!(invoices.get("invoices/paid.txt").await?, "Paid");
//! # Ok(()) }
//! ```
//!
//! Paths are relative to a disk's root. Absolute paths, `..` segments, and backslashes fail with
//! [`InvalidPath`], and local operations can't follow symbolic links outside the root. The
//! `.laravel-storage-` file name prefix is reserved for the temporary files that writes use.
//!
//! A local write replaces its file only after every byte is written. On Unix, it creates files
//! with mode `0644` on public disks and `0600` on others. Once a local operation starts,
//! cancelling its caller doesn't stop it, so a directory deletion can finish after the caller
//! stops waiting. S3 and Laravel Cloud writes upload large files in 8 MiB parts, at most 10,000
//! of them, which limits a streamed upload to about 78 GiB. A failed upload is aborted, but a
//! crashed process can leave an unfinished upload in the bucket, which a bucket lifecycle rule can
//! remove.
//!
//! Moving a file within a local disk renames it and keeps its metadata. Other transfers copy the
//! bytes and may not keep all of the metadata. A local disk from [`build`] isn't mounted, so it
//! can't generate file URLs, but a handler can still return its
//! [download responses](Disk::download).
//! An S3 disk from [`build`] generates public and temporary URLs as usual.
//!
//! # Read-through disks
//!
//! A [read-through disk](crate::config::filesystems::ReadThroughDisk) reads from its primary disk,
//! then from its fallback when the primary has no file. If the primary has the file but can't
//! read it, the read fails rather than trying the fallback. Other operations use these disks:
//!
//! | Operation | Disk |
//! | --- | --- |
//! | Write | Primary |
//! | List or create a directory | Primary only |
//! | Existence or metadata | Primary, then fallback, without copying |
//! | Public or temporary download URL | Primary if the file exists there, otherwise fallback, without copying |
//! | Temporary upload URL | Primary |
//! | Delete a file or directory | Fallback first, then primary |
//!
//! If an operation fails after changing one disk, the change stays. `copy` writes to the primary
//! without promoting the original path. If the primary has the file, `move_to` moves it.
//! Otherwise, `move_to` copies the fallback's file to the new path on the primary and deletes the
//! original from the fallback. Transfers to another disk read through the source, promotion included. A
//! range request reads and discards the bytes before the range, and with promotion, copies the
//! whole file to the primary.
//!
//! # URLs and responses
//!
//! A temporary download URL can't upload a file, and an upload URL can't download one. Local
//! uploads through a temporary URL stream to disk under the global
//! [`LimitUploads`](crate::http::middleware::LimitUploads) limit, whatever their content type,
//! and replace the destination only after the write succeeds. An S3 temporary URL sends the
//! browser to the S3 endpoint, which the browser must be able to reach. Changing its hostname,
//! such as to a CDN's, breaks its signature.
//!
//! [`download`](Disk::download) and [`response`](Disk::response) support `HEAD` requests and a
//! single byte range. On S3, a request whose object changes between the size check and the read
//! fails rather than sending bytes with wrong range headers.
//!
//! A [fake](fake()) disk without a mount, such as a faked S3 disk, still generates URLs. `url`
//! returns an application URL under the disk's name, such as `https://example.com/s3/avatar.png`,
//! and temporary URLs add `expires` and `operation` parameters without a signature. The
//! application doesn't serve these URLs.
pub use *;
pub use ;