I'm using milton server to support webdav protocol in my project but there is a problem. This is my upload (PUT) method code:
public DavFile upload(InputStream is, String name) {
DavFile davFile = null;
if (is != null) {
File newFile = new File(name);
BufferedOutputStream os = null;
byte[] buffer = new byte[1024 * 1024];
int size;
try {
os = new BufferedOutputStream(new FileOutputStream(newFile, false), buffer.length);
while ((size = is.read(buffer)) > 0) {
System.out.println("Log: " + name + " | " + size);
os.write(buffer, 0, size);
}
Util.closeOutputStream(os);
davFile = new DavFile(newFilePath);
} catch (Exception ex) {
Util.writeLog(ex);
} finally {
Util.closeInputStream(is);
Util.closeOutputStream(os);
}
}
return davFile;
}
and this is the output:
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 7834
Log: 722267_119335884931029_2021941220_n.mp4 | 3145
How can i increase the read size of InputStream in milton server? I can not change InputStream to any other type like BufferedInputStream!
In my local computer uploa speed is 27KB/s and this is too slow!!!
There's no reason why that code should be fast or slow. Bytes will be received at the rate they're provided by the network adapter, and using a BufferedInputStream won't help because bytes are already effectively by the network adapter.
I'm very surprised to see local upload speed of 27KB/s, I've never seen antthing that slow before.
I just did a quick test on the milton server i'm currently working on which does very complex processing of files, including chunking and SHA1 calculation, and it gave the following results: UPLOAD time=8541ms SIZE=82,954,392bytes bandwidth= 9,712,491bytes/sec
How have you tested the upload speed, was that from the client or at the server? You can get apparently slow uploads sometimes when measured from the client because of high latency of all the PROPFIND requests the client does before and after the actual upload. That should not be a factor for large files though (Eg 50Mb or more).
If you're testing with Win7 make sure you have cookie authentication enabled otherwise Windows will do every upload twice, first without credentials then again with credentials.
/Brad