Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Large RemoteFile
Large RemoteFile [message #1048668] Wed, 24 April 2013 20:03 Go to next message
Stathis Alexopoulos is currently offline Stathis AlexopoulosFriend
Messages: 42
Registered: September 2010
Member
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 Go to previous message
Stathis Alexopoulos is currently offline Stathis AlexopoulosFriend
Messages: 42
Registered: September 2010
Member
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

Previous Topic:CODES.getAllCodeTypes(..)
Next Topic:howto add a new button to toolbar
Goto Forum:
  


Current Time: Thu Apr 25 23:19:40 GMT 2024

Powered by FUDForum. Page generated in 0.03541 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top