cancel
Showing results for 
Search instead for 
Did you mean: 

Help please to Upload a file from my PC to server's KM

Former Member
0 Kudos

Hello:

I can't Upload correctly a file from my local PC to a KM of the server.

My problem is after that I've uploaded my selected file to KM, when I open or download it from the KM appears blank. I can't get the file Data of the file for uploading

I use a FileUpload.

____________________

<b>

My Context:


File (node)
     |----fileResource  (com.sap.ide.webdynpro.uielementdefinitions.Resource)
     |----fileData  (binary)    
     |----fileName  (String)

</b>

________________________________


wdDoInit(){
     IPrivateUploadDownloadKMView.IFileElement fileBind = wdContext.createFileElement(); 
     wdContext.nodeFile().bind(fileBind); 

     IWDAttributeInfo attInfo = wdContext.nodeFile().getNodeInfo().getAttribute("fileData"); 
     ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
}

onActionSubir(){
      IPrivateUploadDownloadKMView.IFileElement fileElement = wdContext.currentFileElement();
      IWDResource resource = fileElement.getFileResource();

      fileElement.setFileName(resource.getResourceName());
      fileElement.setFileData(fileData);

      byte[] fileData=new byte[resource.read(false).available()];
			 
      fileElement.setFileData(fileData);

      fileName = fileElement.getFileName();
			 
     try{			 
           File file = new File(fileName); 
           FileOutputStream out = new FileOutputStream(file); 
           out.write(fileElement.getFileData()); 
           out.close(); 

           fin = new FileInputStream(fileName); 
           fin.read(); 
			 
           Content content = new Content(fin,null, -1); 
            IResource newResource = folder.createResource(fileElement.getFileName(),null, content);
      }
      catch(Exception e){
             IWDMessageManager mm = wdControllerAPI.getComponent().getMessageManager();
             mm.reportWarning("error: "+e.getMessage());
      }
}

Can you help me?, any sugestions to solve my problem or improve my code?

Regards

Jonatan.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

check this blog

/people/rohit.radhakrishnan/blog/2005/05/27/uploading-files-to-km-repository-using-webdynpro-apis