Stylianos Gakis
08/09/2022, 11:42 AMfun DefaultUpload.Builder.content(file: File): DefaultUpload.Builder
here it seems like the line file.source().buffer()
shouldn’t be there? Not an okio expert so bear with me 😄
We were using this function at some place where we forgot to migrate to File.toUpload()
and we were experiencing that empty files were being sent over to the backend. And from my understanding I guessed that it probably happens from reading its contents somewhere since they’re readable only once. And in this function its seems like we’re reading the entire file into a buffer effectively emptying it out for the next time we do buffer()
again, so that is why it’s then empty. After we migrated to File.toUpload()
it seems like our files get sent to the backend properly. Anyone more proficient with okio can chime in to help me understand? 😊mbonnin
08/09/2022, 11:44 AMStylianos Gakis
08/09/2022, 11:46 AMmbonnin
08/09/2022, 11:47 AMBufferedSource
but shouldn't read anythingStylianos Gakis
08/09/2022, 11:51 AMmbonnin
08/09/2022, 11:52 AMStylianos Gakis
08/09/2022, 3:04 PM.fileName(file.name)
. When I added that myself it simply worked. It seems like this has more to do with our backend then, since the file name should be possible to be null.
So tl;dr I think it was our backend giving us the wrong error making me think we were sending an empty file, but the problem was somewhere else.
False alarm, but at least we got rid of one line of code so that’s always positive 😂mbonnin
08/09/2022, 3:05 PM