-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FtpUpload Buffer Size #7
Comments
If the uploaded file is smaller than the buffer size, the buffer size should be adjusted to the file size. Will be fixed in the next release! |
I saw that the buffer size is already adjusted if the file or part is smaller. I tried to reproduce it but my upload worked. Same checksum on client and server. I tested it with a binary file with the following sizes:
Could you please tell me the exact size of your file? |
The file size is 126.976 byte |
Sorry I'm not able to reproduce it, even with this size. Since it's smaller than the buffer size, the buffer size is adjusted correctly and the file is uploaded all at once. |
How can I help you? |
I published a new Version (0.6.0) which adds a configurable buffer size as a temporary workaround. Can you tell us what FTP Server software you use? |
As stated in #8 I'll set up a Pure-FTPd testsystem to check against it. |
Temporary workaround with the configurable buffersize did not work. I will investigate this further. |
I can confirm this is broken. Whenever I want to upload a jpeg image with like 1-2 megabytes, it arrives in a broken state on the server. Did you manage to fix it already? |
Hey guys, I opened a small PR. Actually a simple flush was everything that was needed in order to make sure that all the data was piped to the FTP socket. |
Thank you! That solution was too easy to notice ... I'll publish a new Version now. |
I am sorry, I was not testing this correctly. After my "fix" it just worked a couple of times in a row. But apparently, it is not fixed. Now I got corrupted files again, so there must be something else that is going wrong. I am debugging it further. Also changing it from this raw socket to a normal one and piping a file read stream into a normal socket, waiting for it to flush and so on is not fixing things :P So the error must be at some other place than the socket that uploads the data. Maybe the disconnect from the server is still too early. What was the reason you were only using sync methods by the way for this plugin? |
Hi,
I am using ftpclient to upload files from my devices to my FTP site.
Everything works fine, but when the transferred file is small (minus 1 Mb), I found a damaged partial file on my FTP site.
Below my code:
bool uploadFile(String PathFileName) {
FTPClient ftpClient = new FTPClient(Host, user: Username, pass: Password);
try {
ftpClient.connect();
ftpClient.uploadFile(new File(PathFileName));
sleep(Duration(seconds: 5));
ftpClient.disconnect();
return true;
} catch (ex) {
debugPrint(ex.toString());
return false;
}
}
To workaround I insert a sleep before Disconnect method.
The right solution is to change the Buffer Size in the class FileUpload {
static const int _BUFFER_SIZE = 1024 * 1024;
I tried to set the _BUFFER_SIZE = 1024; and in this way I don't need to use the sleep.
Seems that the function uploadFile in your class FileUpload exit before transfer is complete. So when my program call disconnect method because it think the transfer is complete, it drops the transfer. I hope the description of my issue is clear.
I'am using android 8, ftpclient: ^0.5.0
The text was updated successfully, but these errors were encountered: