Skip to content

Conversation

@OS-pedrogustavobilro
Copy link
Contributor

Description

Partially addresses ionic-team/capacitor-file-transfer#10

The upload delegate was receiving -1 for totalBytesExpectedToSend. According to the apple docs , there's a few ways in which we can do this, opted going with adding the "Content-Length" header - which was done in the old cordova plugin.

Furthermore, I noticed this error in logs in XCode when chunkedMode is true:

The request of a upload task should not contain a body or a body stream,
use upload(for:fromFile:), upload(for:from:),
or supply the body stream through the urlSession(_:needNewBodyStreamForTask:) delegate method.

Which I also fixed in this PR by providing the input stream via the upload delegate instead of directly in the request object.

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Tests

You may generate a xcframework using the scripts/build_framework.sh and test in the Capacitor Example app - https://github.com/ionic-team/capacitor-file-transfer

Checklist

  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

For progress notifications to work
To avoid this error showing up on XCode logs - The request of a upload task should not contain a body or a body stream, use upload(for:fromFile:), upload(for:from:), or supply the body stream through the urlSession(_:needNewBodyStreamForTask:) delegate method.
@OS-pedrogustavobilro
Copy link
Contributor Author

Apologies, turns out the capacitor example app wasn't working to test the issue - PR was opened to fix that ionic-team/capacitor-file-transfer#19

@alexgerardojacinto alexgerardojacinto self-requested a review August 25, 2025 11:58
@OS-pedrogustavobilro OS-pedrogustavobilro merged commit 756ac7b into main Aug 25, 2025
1 check passed
@OS-pedrogustavobilro OS-pedrogustavobilro deleted the fix/upload-progress branch August 25, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants