Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Store files on server with the RemoteFileService
Store files on server with the RemoteFileService [message #1077379] Thu, 01 August 2013 16:06 Go to next message
Mirjam B. is currently offline Mirjam B.Friend
Messages: 8
Registered: June 2013
Junior Member
Hi, is there any way to use the RemoteFileService for creating files on a server (Tomcat)?
I appreciate any idea Smile
Re: Store files on server with the RemoteFileService [message #1091701 is a reply to message #1077379] Wed, 21 August 2013 21:47 Go to previous message
Lukas Huser is currently offline Lukas HuserFriend
Messages: 42
Registered: March 2010
Hi Mirjam

Yes, this should be possible.

When you look at the interface IRemoteFileService, you will notice the method declaration
void putRemoteFile(RemoteFile spec) throws ProcessingException;

and indeed, this method will allow you to store a RemoteFile on the server. Well, at least if you call this service method on the server itself. It is not allowed to call this method directly from the client -- note the RemoteServiceAccessDenied annotation. (You will get a SecurityException, if you try to do so.)

The reason for this restriction probably are security and/or performance considerations. Before you upload any file to your server from the client, you should do a thorough input validation on the file content and restrict the file size, etc.

That said, you can easily expose the method to the client by defining your own service and simply delegate to the existing implementation of the RemoteFileService to do the work.

Sample Code
Service interface in shared bundle. Register it as a proxy service on client side.
public interface IUploadService extends IService {
  void storeFile(RemoteFile file) throws ProcessingException;

Service implementation in server bundle.
public class UploadService extends AbstractService implements IUploadService {
  public void storeFile(RemoteFile file) throws ProcessingException {

You can now use this service on client side, e.g. to upload a file chosen by the user.
public class UploadForm extends AbstractForm {

  // GUI code omitted

  public class ModifyHandler extends AbstractFormHandler {
    public void execLoad() throws ProcessingException {
      getFileField().setTypeLoad(true); // FileField extends AbstractFileChooserField

    public void execStore() throws ProcessingException {
      File file = getFileField().getValueAsFile();
      if (file != null) {

        // TODO thorough input validation (file size, content etc.)

        // all files are stored in subfolder "fileStore", relative to the root folder of the RemoteFileService
        RemoteFile remoteFile = new RemoteFile("fileStore", file.getName(), file.lastModified());
        try {
          remoteFile.readData(file); // read actual file content
        catch (IOException e) {
          throw new ProcessingException("Error while reading file.", e);
        IUploadService uploadService = SERVICES.getService(IUploadService.class);

  • Attachment: upload.png
    (Size: 5.35KB, Downloaded 261 times)
Previous Topic:Hyperlink Action not working in RAP
Next Topic:Adding Persistence Option to Forms and Services (CRUD)?
Goto Forum:

Current Time: Sat Jun 23 04:56:05 GMT 2018

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

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

Back to the top