LxFTPRequest
LxFTPRequest copied to clipboard
Upload PDF file not successful
I tried uploading a pdf file to my ftp server. Application notify that uploading is successful but I can not open the uploaded file and uploaded file size is small than local file.
Thank you for your attention. Maybe my notification has some error, and the phenomenon you see is because of the network problem. I'm busy recently, I want to fix it some other day. Thanks for your supporting again !
This happens with even a regular ~10KB png file.
It's OK with png file.
I went in and started logging bytes written vs read and those things. All those seem fine however my png file that is 7118
bytes only gets uploaded up-to 4520
bytes. Another image 226595
bytes, only 141000
bytes get uploaded. But the weird thing is the logs show everything well. I will try looking more at the source code myself later but it'd be great if a fix could be put up :D
Seems like calling [request stop];
in the condition (bytesRead == 0)
causes this issue, as this closes the stream but all of the data still hasn't been uploaded yet.
Why does this not get called? kCFStreamEventEndEncountered
The whole problem would be solved then. Until then I'm manually gonna have to close the stream from somewhere.
I was also getting randomly truncated uploads until I found the magic line to remove:
679: CFWriteStreamSetProperty(self.writeStream, kCFStreamPropertyFTPAttemptPersistentConnection, kCFBooleanFalse);
After commenting out this line, all my uploads appear to be complete.