Large RemoteFile [message #1048668] |
Wed, 24 April 2013 20:03 |
|
Hello,
Does anyone has experience with large remote files?
I tried the following code but did not work.
private void getFileInParts() throws ProcessingException, IOException {
IRemoteFileService service = SERVICES.getService(IRemoteFileService.class);
RemoteFile fileHeader = service.getRemoteFileHeader( new RemoteFile("versions", "recomsClient.zip", 0L));
OutputStream out = new FileOutputStream( new File("/tmp/recomsClient.zip"));
while( fileHeader.hasMoreParts()) {
RemoteFile filePart = service.getRemoteFilePart(fileHeader, 1);
out.write( filePart.extractData());
}
}
it seems that the problem lies in hasMoreParts() where is implemented as follows.
public boolean hasMoreParts() {
return getContentLength() == RemoteFile.DEFAULT_MAX_BLOCK_SIZE;
}
Any comment is welcomed.
|
|
|
Re: Large RemoteFile [message #1048912 is a reply to message #1048668] |
Thu, 25 April 2013 05:19 |
|
Finally, i managed to get a large file with the following code.
RemoteFile fileHeader = service.getRemoteFileHeader(fileRequest);
long fileLength = fileHeader.getContentLength();
long partsCount = (fileLength / RemoteFile.DEFAULT_MAX_BLOCK_SIZE);
for( int i = 0; i <= partsCount; i++)
{
RemoteFile filePart = service.getRemoteFilePart(fileRequest, i);
byte[] data = filePart.extractData();
out.write( data);
}
I dont like it, because it is error-prone but if there is no other proposed implementation, i will add it to wiki.
[Updated on: Thu, 25 April 2013 05:20] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03541 seconds