You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Persist diskName per attachment in the JSON metadata (feature request) #37
I have several disks configured (e.g. s3 and local) and I'd like to spread uploaded photos across both of them — choosing the target disk dynamically at upload time rather than hardcoding a single disk per attribute via the @attachment({ disk: '...' }) decorator.
The problem is that the disk (or diskName) is not persisted in the JSON metadata stored in the database. As a result, once a file is written, the package has no record of which disk it actually lives on — it always resolves the disk from the decorator/config at read time. This makes it impossible to reliably serve, generate URLs for, or delete files when different rows of the same model are stored on different disks.
Describe the solution you'd like
Store the diskName per attachment inside the persisted JSON metadata, alongside the existing fields (name, extname, mimeType, size, etc.). On read (URL generation, deletion, etc.), the package should use the diskName from the stored metadata when present, and only fall back to the decorator/config disk when it's absent (for backward compatibility).
Describe alternatives you've considered
Hardcoding the disk per attribute via the decorator, but this prevents distributing files of the same model/attribute across multiple disks.
Additional context
This would enable use cases such as load-balancing storage across multiple backends, gradual migration between disks, or routing files to different disks based on runtime conditions.
For example, I currently have an application in production that uses the 'fs' disk (local disk), and i added an new disk (cloudflare R2). I tried my best to migrate my photos, but I couldn't get it to work.
Furthermore, when I pushed, I thought "it will automatically fetch the photo from the correct disk," but I was wrong, since you use the default disk.
It would be great to be able to add the disk to the JSON payload stored in the database, so that when the URL is computed, it pulls from the correct disk.
Activity
batosai commentedon May 26, 2026
Hello,
Could you tell me a bit more about how you are using (or planning to use) the package, both for storing and reading files?
A few concrete usage examples would help me better understand your needs and the related constraints.
Thanks 🙂
PandaGuerrier commentedon May 27, 2026
Hi,
For example, I currently have an application in production that uses the 'fs' disk (local disk), and i added an new disk (cloudflare R2). I tried my best to migrate my photos, but I couldn't get it to work.
Furthermore, when I pushed, I thought "it will automatically fetch the photo from the correct disk," but I was wrong, since you use the default disk.
It would be great to be able to add the disk to the JSON payload stored in the database, so that when the URL is computed, it pulls from the correct disk.
batosai commentedon May 27, 2026
I understand. I’ll look to add this.
batosai commentedon May 28, 2026
Hello, I just created version 5.2.0-beta.2. Would you be able to help me test it?
Thanks