Skip to content

refactor: FileUploader.upload now uses StreamedRequest - #3695

Merged
nielsenko merged 5 commits into
serverpod:mainfrom
nielsenko:uploader-streaming
Jun 23, 2025
Merged

nielsenko merged 5 commits into
serverpod:mainfrom
nielsenko:uploader-streaming

Conversation

@nielsenko

@nielsenko nielsenko commented Jun 19, 2025 •

Copy link
Copy Markdown
Collaborator

Strive to reduce memory pressure during upload by supporting streamed upload via StreamedRequest.

Updates http package dependency and refactors FileUploader for improved stream handling.

Closes: #3692

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

If you need help, consider asking for advice on the discussion board.

Breaking changes

None

Summary by CodeRabbit

  • Refactor

    • Improved and unified the file upload process for better reliability and consistency.
    • Enhanced error handling and streamlined the upload logic for file uploads.
  • Chores

    • Updated the minimum required version of the http package to 1.1.0 across all packages, modules, templates, and tests to ensure compatibility with newer features and fixes.
  • Tests

    • Added tests for streaming binary uploads and uploader state validation to improve coverage and reliability.

@coderabbitai

coderabbitai Bot commented Jun 19, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

"""

Walkthrough

The changes update the minimum required version of the http package from 1.0.0 to 1.1.0 across multiple pubspec.yaml files in the repository, including core packages, integrations, templates, and test projects. Additionally, the FileUploader class in packages/serverpod_client/lib/src/file_uploader.dart is refactored to perform streaming uploads, preventing full in-memory buffering.

Changes

File(s) Change Summary
All pubspec.yaml files in integrations, modules, packages, templates, tools, and tests Raised lower bound of http dependency from >=1.0.0 to >=1.1.0
packages/serverpod_client/lib/src/file_uploader.dart Refactored FileUploader to stream uploads directly from input stream, avoiding full buffering; added extension for stream conversion; updated method signatures
tests/serverpod_test_server/test_e2e/cloud_storage_test.dart Added streaming upload tests, infinite byte stream generator, chunking extension, and uploader reuse validation tests

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant FileUploader
    participant HTTPServer

    Client->>FileUploader: upload(stream, [length])
    FileUploader->>FileUploader: Convert stream to ByteStream (if needed)
    FileUploader->>HTTPServer: Send HTTP request with stream as body (no full buffering)
    HTTPServer-->>FileUploader: HTTP response (status code)
    FileUploader-->>Client: Return success/failure
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement streaming upload in FileUploader to avoid loading full stream into memory (#3692) ✅

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found. All modifications are related to raising the minimum http package version or refactoring the FileUploader to address the streaming upload requirement.
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97c9e77 and dd608d5.

📒 Files selected for processing (1)
  • tests/serverpod_test_server/test_e2e/cloud_storage_test.dart (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/serverpod_test_server/test_e2e/cloud_storage_test.dart
⏰ Context from checks skipped due to timeout of 90000ms (55)
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/serverpod_auth/serverpod_auth_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/serverpod_auth/serverpod_auth_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in tests/serverpod_new_auth_test/serverpod_new_auth_test_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in tests/serverpod_test_module/serverpod_test_module_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_server with Flutter 3.24.0
  • GitHub Check: Flutter unit tests (3.32.1, ubuntu-latest, packages/serverpod_flutter)
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in tests/serverpod_new_auth_test/serverpod_new_auth_test_server with Flutter 3.24.0
  • GitHub Check: Serverpod E2E IO tests (3.24.0)
  • GitHub Check: Flutter unit tests (3.32.1, windows-latest, packages/serverpod_flutter)
  • GitHub Check: Flutter unit tests (3.24.0, windows-latest, packages/serverpod_flutter)
  • GitHub Check: Serverpod E2E IO tests (3.32.1)
  • GitHub Check: Serverpod concurrent integration tests (server) (3.32.1)
  • GitHub Check: Bootstrap tests (3.32.1, windows-latest, tests/bootstrap_project)
  • GitHub Check: Serverpod integration tests (flutter)
  • GitHub Check: Serverpod concurrent integration tests (server) (3.24.0)
  • GitHub Check: Bootstrap tests (3.24.0, windows-latest, tests/bootstrap_project)
  • GitHub Check: Bootstrap tests (3.32.1, ubuntu-latest, tests/bootstrap_project)
  • GitHub Check: Serverpod integration tests (server) (3.24.0)
  • GitHub Check: Bootstrap tests (3.24.0, ubuntu-latest, tests/bootstrap_project)
  • GitHub Check: CLI e2e tests (3.32.1, ubuntu-latest, tests/serverpod_cli_e2e_test)
  • GitHub Check: Serverpod integration tests (3.32.1, packages/serverpod_shared)
  • GitHub Check: Migration e2e tests (3.24.0)
  • GitHub Check: CLI e2e tests (3.24.0, ubuntu-latest, tests/serverpod_cli_e2e_test)
  • GitHub Check: Migration e2e tests (3.32.1)
  • GitHub Check: Serverpod integration tests (server) (3.32.1)
  • GitHub Check: Version change test
  • GitHub Check: Unit tests Web (3.32.1, windows-latest)
  • GitHub Check: Serverpod E2E web tests (3.24.0)
  • GitHub Check: Unit tests Web (3.24.0, ubuntu-latest)
  • GitHub Check: Unit tests Web (3.32.1, ubuntu-latest)
  • GitHub Check: Unit tests Web (3.24.0, windows-latest)
  • GitHub Check: Serverpod E2E web tests (3.32.1)
  • GitHub Check: Unit tests IO (3.24.0, windows-latest)
  • GitHub Check: dart analyze downgrade (3.32.1, ubuntu-latest)
  • GitHub Check: Unit tests IO (3.32.1, windows-latest)
  • GitHub Check: Unit tests IO (3.32.1, ubuntu-latest)
  • GitHub Check: Unit tests IO (3.24.0, ubuntu-latest)
  • GitHub Check: dart analyze downgrade (3.32.1, windows-latest)
  • GitHub Check: dart analyze downgrade (3.24.0, ubuntu-latest)
  • GitHub Check: dart analyze downgrade (3.24.0, windows-latest)
  • GitHub Check: dart analyze latest (3.32.1, ubuntu-latest)
  • GitHub Check: serverpod generate (3.24.0)
  • GitHub Check: update pubspecs (3.32.1)
  • GitHub Check: dart analyze (3.24.0, ubuntu-latest)
  • GitHub Check: serverpod generate (3.32.1)
  • GitHub Check: dart analyze latest (3.32.1, windows-latest)
  • GitHub Check: dart analyze (3.24.0, windows-latest)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nielsenko nielsenko self-assigned this Jun 19, 2025
@nielsenko
nielsenko force-pushed the uploader-streaming branch 5 times, most recently from 01c3a43 to dea9bab Compare June 20, 2025 06:53
@nielsenko
nielsenko marked this pull request as ready for review June 20, 2025 06:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/serverpod_client/lib/src/file_uploader.dart (1)

75-78: Address the TODO: Add error logging.

The TODO comment indicates missing error logging. Consider adding appropriate logging to help with debugging upload failures.

Would you like me to suggest a logging implementation that preserves the current return behavior while providing better debugging information?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 169187f and dea9bab.

📒 Files selected for processing (21)
  • integrations/serverpod_cloud_storage_gcp/pubspec.yaml (1 hunks)
  • integrations/serverpod_cloud_storage_s3/pubspec.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server/pubspec.yaml (1 hunks)
  • modules/serverpod_auth/serverpod_auth_server/pubspec.yaml (1 hunks)
  • modules/serverpod_chat/serverpod_chat_server/pubspec.yaml (1 hunks)
  • packages/serverpod/pubspec.yaml (1 hunks)
  • packages/serverpod_client/lib/src/file_uploader.dart (3 hunks)
  • packages/serverpod_client/pubspec.yaml (1 hunks)
  • templates/pubspecs/integrations/serverpod_cloud_storage_gcp/pubspec.yaml (1 hunks)
  • templates/pubspecs/integrations/serverpod_cloud_storage_s3/pubspec.yaml (1 hunks)
  • templates/pubspecs/modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server/pubspec.yaml (1 hunks)
  • templates/pubspecs/modules/serverpod_auth/serverpod_auth_server/pubspec.yaml (1 hunks)
  • templates/pubspecs/modules/serverpod_chat/serverpod_chat_server/pubspec.yaml (1 hunks)
  • templates/pubspecs/packages/serverpod/pubspec.yaml (1 hunks)
  • templates/pubspecs/packages/serverpod_client/pubspec.yaml (1 hunks)
  • templates/pubspecs/tests/bootstrap_project/pubspec.yaml (1 hunks)
  • templates/pubspecs/tests/serverpod_test_server/pubspec.yaml (1 hunks)
  • templates/pubspecs/tools/serverpod_cli/pubspec.yaml (1 hunks)
  • tests/bootstrap_project/pubspec.yaml (1 hunks)
  • tests/serverpod_test_server/pubspec.yaml (1 hunks)
  • tools/serverpod_cli/pubspec.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Serverpod E2E web tests (3.24.0)
  • GitHub Check: Serverpod E2E web tests (3.32.1)
  • GitHub Check: Serverpod integration tests (server) (3.32.1)
  • GitHub Check: Unit tests IO (3.32.1, windows-latest)
  • GitHub Check: Unit tests IO (3.24.0, windows-latest)
  • GitHub Check: Serverpod integration tests (server) (3.24.0)
  • GitHub Check: serverpod generate (3.24.0)
  • GitHub Check: serverpod generate (3.32.1)
  • GitHub Check: Migration e2e tests (3.32.1)
  • GitHub Check: Migration e2e tests (3.24.0)
  • GitHub Check: dart analyze downgrade (3.32.1, windows-latest)
  • GitHub Check: dart analyze downgrade (3.24.0, windows-latest)
🔇 Additional comments (26)
packages/serverpod_client/lib/src/file_uploader.dart (6)

3-3: LGTM: Required import for async utilities.

The dart:async import is correctly added to support the unawaited function used in the streaming implementation.


24-28: LGTM: Efficient ByteStream creation and delegation.

The refactored uploadByteData method efficiently creates a ByteStream from the buffer and delegates to the unified _upload method. This maintains the same interface while leveraging the new streaming architecture.


31-32: LGTM: Enhanced method signature with optional length parameter.

The addition of the optional length parameter is a good enhancement that enables more efficient streaming when the content length is known upfront. The use of the extension method to convert to ByteStream is clean.


34-54: LGTM: Proper streaming implementation for binary uploads.

The binary upload implementation correctly uses StreamedRequest and pipes the stream directly to the request sink using unawaited. This achieves the goal of reducing memory pressure by avoiding buffering the entire content in memory.


65-74: LGTM: Clean multipart request handling.

The multipart request construction and field handling is implemented correctly. The response status code check (204) is appropriate for multipart uploads.


117-123: LGTM: Efficient stream conversion extension.

The extension method correctly checks if the stream is already a ByteStream to avoid unnecessary conversion, which is a good optimization. The implementation is clean and follows Dart conventions.

modules/serverpod_auth/serverpod_auth_server/pubspec.yaml (1)

22-22: Consistent HTTP version bump to support StreamedRequest
Updated the http dependency to >=1.1.0 <2.0.0, aligning with the newly introduced StreamedRequest usage in FileUploader.

templates/pubspecs/tools/serverpod_cli/pubspec.yaml (1)

17-17: Align HTTP constraint with core packages
Raised the lower bound for http to >=1.1.0 <2.0.0 to ensure availability of streaming APIs. This matches the other pubspec templates.

integrations/serverpod_cloud_storage_gcp/pubspec.yaml (1)

18-18: Update HTTP dependency for stream support
Bumped http to >=1.1.0 <2.0.0, consistent with the rest of the repository and required for streamed uploads.

packages/serverpod_client/pubspec.yaml (1)

16-16: Sync HTTP version with client requirements
Lower bound of http updated to >=1.1.0 <2.0.0 so that FileUploader can utilize StreamedRequest without version conflicts.

tools/serverpod_cli/pubspec.yaml (1)

18-18: Maintain uniform HTTP version across CLI tools
Adjusted http constraint to >=1.1.0 <2.0.0 in the CLI pubspec, matching templates and modules for streaming support.

packages/serverpod/pubspec.yaml (1)

26-26: ```shell
#!/bin/bash

List all pubspec.yaml files with any http dependency line

rg -n "http:" --glob '**/pubspec.yaml'

Specifically search for the old constraint pattern

rg -n "http:.*>=1.0.0 <2.0.0" --glob '**/pubspec.yaml'


</details>
<details>
<summary>templates/pubspecs/modules/serverpod_chat/serverpod_chat_server/pubspec.yaml (1)</summary>

`15-15`: **Bump HTTP dependency version in chat server template**

Aligned HTTP lower bound to `>=1.1.0` in the chat server template to match updated streaming requirements.

</details>
<details>
<summary>templates/pubspecs/packages/serverpod_client/pubspec.yaml (1)</summary>

`15-15`: **Bump HTTP dependency version in client template**

Updated HTTP lower bound to `>=1.1.0` in the client template for consistency with streaming support.

</details>
<details>
<summary>modules/serverpod_chat/serverpod_chat_server/pubspec.yaml (1)</summary>

`16-16`: **Bump HTTP dependency version in chat module**

Aligned HTTP lower bound to `>=1.1.0` for the chat module’s pubspec to ensure compatibility with streamed uploads.

</details>
<details>
<summary>templates/pubspecs/integrations/serverpod_cloud_storage_gcp/pubspec.yaml (1)</summary>

`17-17`: **Bump HTTP dependency version in GCP integration template**

Raised HTTP lower bound to `>=1.1.0` in the GCP integration template to support streamed requests.

</details>
<details>
<summary>integrations/serverpod_cloud_storage_s3/pubspec.yaml (1)</summary>

`17-17`: **Raise HTTP dependency lower bound to 1.1.0**  
Ensures availability of `StreamedRequest` introduced in `http` v1.1.0 for streaming uploads. Upper bound remains `<2.0.0` for compatibility.

</details>
<details>
<summary>templates/pubspecs/modules/serverpod_auth/serverpod_auth_server/pubspec.yaml (1)</summary>

`21-21`: **Update HTTP package constraint to support streaming**  
Aligns with the refactor requiring `StreamedRequest` in `http` v1.1.0+. Maintains `<2.0.0` to avoid breaking changes.

</details>
<details>
<summary>tests/bootstrap_project/pubspec.yaml (1)</summary>

`11-11`: **Bump HTTP minimum version to 1.1.0 for streaming support**  
Consistent with other projects—ensures new upload logic works with `http` v1.1.0+.

</details>
<details>
<summary>tests/serverpod_test_server/pubspec.yaml (1)</summary>

`14-14`: **Require HTTP ≥1.1.0 to enable StreamedRequest**  
Matches the updated client logic and maintains backward compatibility under `<2.0.0`.

</details>
<details>
<summary>templates/pubspecs/tests/bootstrap_project/pubspec.yaml (1)</summary>

`11-11`: **Increase HTTP lower bound to 1.1.0**  
Guarantees the presence of streaming APIs in `http` v1.1.0+. Upper bound cap remains appropriate.

</details>
<details>
<summary>templates/pubspecs/packages/serverpod/pubspec.yaml (1)</summary>

`25-25`: ```shell
#!/bin/bash
# List every http dependency line across all pubspec.yaml files for manual inspection
find . -type f -name "pubspec.yaml" -print0 | xargs -0 rg -Hn "^\s*http:"
modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server/pubspec.yaml (1)

13-13: Bumped http dependency in generated auth profile server
Lower bound updated to >=1.1.0 <2.0.0, aligning with the core template change. Since this is a generated file, confirm that the corresponding template was updated so regeneration retains this constraint.

templates/pubspecs/integrations/serverpod_cloud_storage_s3/pubspec.yaml (1)

16-16: Aligned http version constraint in S3 integration template
Lower bound bumped to >=1.1.0 <2.0.0, consistent with other templates. The syntax is correct and should satisfy the updated upload implementation requirements.

templates/pubspecs/modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server/pubspec.yaml (1)

12-12: Updated http dependency in auth profile template
Constraint correctly raised to >=1.1.0 <2.0.0, matching the required baseline for StreamedRequest usage.

templates/pubspecs/tests/serverpod_test_server/pubspec.yaml (1)

13-13: Raised http dependency floor in test server template
Lower bound updated to >=1.1.0 <2.0.0, aligning test environments with production dependencies.

@tp tp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ByteData to Stream conversion looks fishy, otherwise the implementation looks fine to me.

Still have some questions though, and without more tests I would probably not ship this right now. But unless I missed more test, smothering this with E2E ones seems longer overdue anyway, and would thus be greatly appreciated I suppose.
(Also should think whether we should be using this FileUploader pattern for the profile image, instead of sending bytes through the Serverpod API and then forwarding that to the bucket store.)

@vanlooverenkoen

Copy link
Copy Markdown
Contributor

As I said before I logged #3633 and used this PR to test my implementation. This PR fixes

  • the invalid lenght error
  • freezing the UI when loading everything in memory.

The upload of my 74mb apk went through without any issues. 🚀 🎉

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/serverpod_test_server/test_e2e/cloud_storage_test.dart (1)

14-25: Fix typo in parameter name.

The extension method logic is correct and efficiently chunks stream elements into fixed-size lists. However, there's a typo in the parameter name.

-  Stream<List<T>> inChunks(int chunckSize) async* {
+  Stream<List<T>> inChunks(int chunkSize) async* {
     var chunk = <T>[];
     await for (final e in this) {
       chunk.add(e);
-      if (chunk.length >= chunckSize) {
+      if (chunk.length >= chunkSize) {
         yield chunk;
         chunk = <T>[]; // new
       }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b373c4 and 9d52a69.

📒 Files selected for processing (2)
  • packages/serverpod_client/lib/src/file_uploader.dart (3 hunks)
  • tests/serverpod_test_server/test_e2e/cloud_storage_test.dart (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/serverpod_client/lib/src/file_uploader.dart
⏰ Context from checks skipped due to timeout of 90000ms (56)
  • GitHub Check: Serverpod integration tests (flutter)
  • GitHub Check: Bootstrap tests (3.24.0, ubuntu-latest, tests/bootstrap_project)
  • GitHub Check: CLI e2e tests (3.32.1, ubuntu-latest, tests/serverpod_cli_e2e_test)
  • GitHub Check: CLI e2e tests (3.24.0, ubuntu-latest, tests/serverpod_cli_e2e_test)
  • GitHub Check: Bootstrap tests (3.32.1, ubuntu-latest, tests/bootstrap_project)
  • GitHub Check: Bootstrap tests (3.32.1, windows-latest, tests/bootstrap_project)
  • GitHub Check: Bootstrap tests (3.24.0, windows-latest, tests/bootstrap_project)
  • GitHub Check: Migration e2e tests (3.24.0)
  • GitHub Check: Serverpod concurrent integration tests (server) (3.24.0)
  • GitHub Check: Migration e2e tests (3.32.1)
  • GitHub Check: Version change test
  • GitHub Check: Serverpod concurrent integration tests (server) (3.32.1)
  • GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/serverpod_auth/serverpod_auth_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in tests/serverpod_test_module/serverpod_test_module_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in tests/serverpod_new_auth_test/serverpod_new_auth_test_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in tests/serverpod_new_auth_test/serverpod_new_auth_test_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/serverpod_auth/serverpod_auth_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server with Flutter 3.24.0
  • GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.24.0
  • GitHub Check: Unit tests Web (3.32.1, ubuntu-latest)
  • GitHub Check: Unit tests Web (3.24.0, ubuntu-latest)
  • GitHub Check: Unit tests Web (3.24.0, windows-latest)
  • GitHub Check: Unit tests IO (3.32.1, ubuntu-latest)
  • GitHub Check: Unit tests Web (3.32.1, windows-latest)
  • GitHub Check: Unit tests IO (3.24.0, windows-latest)
  • GitHub Check: Unit tests IO (3.32.1, windows-latest)
  • GitHub Check: Unit tests IO (3.24.0, ubuntu-latest)
  • GitHub Check: dart analyze downgrade (3.24.0, ubuntu-latest)
  • GitHub Check: dart analyze downgrade (3.32.1, ubuntu-latest)
  • GitHub Check: dart analyze downgrade (3.32.1, windows-latest)
  • GitHub Check: dart analyze downgrade (3.24.0, windows-latest)
  • GitHub Check: update pubspecs (3.32.1)
  • GitHub Check: Flutter unit tests (3.32.1, windows-latest, packages/serverpod_flutter)
  • GitHub Check: Serverpod integration tests (server) (3.24.0)
  • GitHub Check: Flutter unit tests (3.24.0, windows-latest, packages/serverpod_flutter)
  • GitHub Check: Flutter unit tests (3.32.1, ubuntu-latest, packages/serverpod_flutter)
  • GitHub Check: Serverpod integration tests (server) (3.32.1)
  • GitHub Check: Serverpod E2E web tests (3.32.1)
  • GitHub Check: Serverpod E2E web tests (3.24.0)
  • GitHub Check: serverpod generate (3.32.1)
  • GitHub Check: serverpod generate (3.24.0)
  • GitHub Check: dart analyze latest (3.32.1, ubuntu-latest)
  • GitHub Check: dart analyze latest (3.32.1, windows-latest)
  • GitHub Check: dart analyze (3.24.0, windows-latest)
  • GitHub Check: Serverpod E2E IO tests (3.32.1)
  • GitHub Check: Serverpod E2E IO tests (3.24.0)
  • GitHub Check: dart analyze (3.24.0, ubuntu-latest)
  • GitHub Check: Serverpod integration tests (3.32.1, packages/serverpod_shared)
🔇 Additional comments (6)
tests/serverpod_test_server/test_e2e/cloud_storage_test.dart (6)

2-2: LGTM: Import added for async stream functionality.

The dart:async import is correctly added to support the new stream-based testing functionality.


9-12: LGTM: Infinite byte stream generator implementation is correct.

The streamBytes() function correctly generates an infinite stream of bytes cycling from 0 to 255, which is perfect for testing streaming uploads with predictable data patterns.


160-160: LGTM: Test name clarification improves readability.

Renaming the test to explicitly mention "ByteData" improves clarity and distinguishes it from the new streaming test.


176-181: LGTM: Consistent test naming with the upload test.

The test name change maintains consistency with the corresponding upload test and improves test organization.


183-201: Excellent streaming upload test coverage.

This test comprehensively validates the new streaming upload functionality by:

  • Creating a 512-byte stream in 64-byte chunks
  • Verifying successful upload
  • Confirming file verification
  • Validating retrieved file content and size

The test effectively demonstrates the streaming capability that addresses the PR objective of reducing memory pressure during uploads.


203-221: LGTM: Important state management validation.

This test correctly validates that FileUploader instances can only be used once, which is crucial for preventing unintended reuse. The exception message verification ensures proper error handling and user feedback.

@nielsenko
nielsenko force-pushed the uploader-streaming branch from 9d52a69 to eb181eb Compare June 23, 2025 08:36

@SandPod SandPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@tp tp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Just a tiny nit on the test helper, but hey, it's only used internally and easily read through :)

(And seems fine to leave the old tests as is for now, as Alex said this will get an overhaul later this year.)

@nielsenko
nielsenko merged commit 01de844 into serverpod:main Jun 23, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize FileUploader to avoid loading full stream into memory during upload

4 participants