Skip to content

Instantly share code, notes, and snippets.

@Elfsong
Created April 19, 2019 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elfsong/5b2e6898f1ff235acd169c475584430d to your computer and use it in GitHub Desktop.
Save Elfsong/5b2e6898f1ff235acd169c475584430d to your computer and use it in GitHub Desktop.
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