Apollo-ios: Retry Uploading Files is failing

Created on 13 Mar 2020  路  7Comments  路  Source: apollographql/apollo-ios

Hello Everyone,

I found an issue while using the retry handling for Uploading Files, the problem is that in the retry request call (second request call) the Files Content are not being sent in the Request, the framework is recreating the whole request in every retry call so the InputStream is not retrieving the Data once it has been already read, so in the retry call (second request) the InputStream data is nil.

The inputStream.hasBytesAvailable is always returning false in every retry call (after the first call)
https://github.com/apollographql/apollo-ios/blob/9987f9261903cd80c5d61dab7e9232539d16277c/Sources/Apollo/MultipartFormData.swift#L121

Maybe a fix could be recreate a new InputStream object every time we are going to create a request.

Thanks

bug uploading

All 7 comments

Ooh, yeah, because the input stream gets exhausted after it's read once. Yick.

I'll tag this as a bug, but I'll be honest, it's probably going to be a while before I can get to this. Would be happy to look at any PRs, but it does seem like the automatic retry functionality is not great for use with uploads because of this.

One thing I will note for this and all other uploading issues: One strategy we've seen have folks have better long-term success with over GQL-based uploads is uploading the file to another service (such as S3 or even your own backend) and then only sending the URL of the file via GraphQL. This is an article about the web, but it's got useful examples.

Thanks @designatednerd this is the PR https://github.com/apollographql/apollo-ios/pull/1086 with the fix that I propose, please take a look

hey @designatednerd thanks for merging my PR, so do you have any news about the new release?
Thanks

Shooting for today, have to do some doc updates and testing first

This has shipped with 0.24.0!

Thanks @designatednerd

Was this page helpful?
0 / 5 - 0 ratings