"operation canceled" sending image to S3


I am trying to upload images to S3 similar to how is described here

but using a function called directly from the Swift SDK instead of a trigger. I am using the same Swift code for image handling which ensures the image is compressed below 1MB. I am getting the “operation canceled” error, which in the past has usually been a timeout error but this time I’m getting the error well before the 120s time limit. The function occasionally succeeds, but the resulting image in S3 is broken (I mention this just to demonstrate that there isn’t an issue with the S3 config).

Any idea why I am getting this error? More generally, sending an image directly to a realm function to upload to S3 seems like a common use case, are there any examples of it out there? The documentation for the S3 part is good but I haven’t found much out there on the Swift side.