Skip to content

Instantly share code, notes, and snippets.

@Elfsong Elfsong/server.java
Created Apr 19, 2019

Embed
What would you like to do?
Sent file in blocksize
// TODO: FILE_BYTES_REQUEST
for (int initial_position = 0; initial_position < qq.fileDescriptor.fileSize; ) {
long offset = 0;
long remained = qq.fileDescriptor.fileSize - initial_position;
if (remained > blockSize) {
offset = blockSize;
} else {
offset = remained;
}
ByteBuffer content = fileSystemManager.readFile(qq.fileDescriptor.md5, initial_position, offset);
String encoded = Base64.getEncoder().encodeToString(content.array());
//TODO: sent encode buffer
initial_position += offset;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.