Repository navigation
refactor: Update CloudStorage interface - #5621
Merged
Merged
Conversation
Isakdl
reviewed
Aug 21, 2026
Isakdl
reviewed
Aug 21, 2026
Isakdl
reviewed
Aug 21, 2026
nielsenko
requested changes
Aug 21, 2026
Collaborator
There was a problem hiding this comment.
I think we should take the opportunity to change more. Here are my suggestions (with the help of claude for the table). So File on all file related methods, direction on Uri related ones (Download/Upload), drop Direct, etc.
CloudStorage
| Before | After | Change |
|---|---|---|
storeFile(byteData, expiration, verified) -> void |
storeFile(byteData, options) -> void |
expiration -> options; verified removed |
storeFileWithOptions(byteData, expiration, verified, options) |
(deleted) | merged into storeFile |
retrieveFile() -> ByteData? |
retrieveFile() -> ByteData? |
unchanged |
| (none) | statFile() -> FileStat? |
new |
fileExists() -> bool |
fileExists() -> bool |
now a default method over statFile |
deleteFile() -> void |
deleteFile() -> void |
unchanged |
getPublicUrl() -> Uri? |
publicDownloadUrl() -> Uri? |
renamed |
| (none) | temporaryDownloadUrl(options) -> Uri? |
new |
createDirectFileUploadDescription(expirationDuration, maxFileSize) -> String? |
createUploadDescription(options) -> String? |
renamed; both params -> options |
createDirectFileUploadDescriptionWithOptions(..., options) |
(deleted) | merged into createUploadDescription |
verifyDirectFileUpload() -> bool |
verifyUpload() -> bool |
renamed |
StorageAccess
| Before | After | Change |
|---|---|---|
storeFile(byteData, expiration, preventOverwrite) |
storeFile(byteData, options) |
flattened params -> StoreFileOptions |
createDirectFileUploadDescription(expirationDuration, maxFileSize, contentLength, preventOverwrite) |
createUploadDescription(options) |
4 params -> UploadOptions |
getPublicUrls(paths) -> List<Uri?> |
publicDownloadUrls(paths) |
renamed |
| (none) | temporaryDownloadUrl(options), statFile() |
new pass-throughs |
| null-check repeated 8x | _storage(storageId) helper |
dedup |
| (none) | contentLength <= maxFileSize check |
hoisted from 3 impls |
Types
| Type | Fields | Used by |
|---|---|---|
StoreFileOptions |
expiration, preventOverwrite, metadata |
storeFile |
UploadOptions |
expirationDuration, maxFileSize, contentLength, preventOverwrite, metadata |
createUploadDescription |
TemporaryDownloadUrlOptions |
expirationDuration, downloadFileName, contentType |
temporaryDownloadUrl |
FileMetadata |
contentType, cacheControl, contentDisposition, contentEncoding, custom |
write-time; in both upload options types |
FileStat |
size, lastModified, contentType, etag, custom |
read-time; statFile() |
CloudStorageOptions |
(removed) | split into the 3 above |
CloudStorageWithOptions |
(removed) | deleted |
Behaviour
| Area | Before | After |
|---|---|---|
| Unsupported option | silently dropped | must throw CloudStorageException |
preventOverwrite on DB direct upload |
accepted, ignored | throws (or ON CONFLICT DO NOTHING + migration) |
verified: false |
on public interface, ignored by S3 and GCP | DatabaseCloudStorage.storeUnverifiedFile |
| Content type, DB reads | guessed from 12-entry map | stored value; extension guess as fallback |
fileExists on S3 |
HEAD, discards headers | HEAD via statFile, headers kept |
expiration on DB entries |
written, never enforced | enforced (prerequisite for download tokens) |
…face and support metadata
…nd harden path for silently ignored flags
Crazelu
force-pushed
the
refactor/cloud-storage
branch
from
August 24, 2026 17:44
2b435f4 to
9168b91
Compare
Crazelu
marked this pull request as ready for review
August 24, 2026 19:38
test: Add additional tests for cloud storage refactor
nielsenko
reviewed
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CloudStorage interface now supports metadata and temporary URLs. Upload description is now typed. Methods that previously had nullable return types now opt for throwing exceptions instead of returning null.
This refactor comes with hardened validation of provided options with exceptions thrown instead of silently ignoring.
Closes #4848
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.If you need help, consider asking for advice on the discussion board.
Breaking changes
CloudStoragemethods have been replaced or changed shape.CloudStoragemethods now throw exceptions instead of doing nothing or returning null.preventOverwriteare no longer silently ignored by implementations that don't support them; an exception is thrown instead.