on 07-23-2009 3:57 PM
Hi experts!
In the application that i'm developing I need to write a custom file (serialized object) inside a component and read the content inside another component.
I know how to serialize and de-serialize objects, so my question is: can I define the folder where this file goes, like in the same way I can use the mimes folder to store image files? For example: /src/logs/MyFile.dat.
Thanks in advance.
Osvaldo Silva
Solved the problem using KM to store the serialized file.
I used this code (or something like this):
...
IResource file;
IContent fileContent;
...
// READING
// file contains the reference to the needed KM file
fileContent = file.getContent();
ObjectInputStream ois = new ObjectInputStream(fileContent.getInputStream());
Vector serializedObject = (Vector)ois.readObject();
...
// WRITING
...
// write to server folder
ObjectOutput out = new ObjectOutputStream(new FileOutputStream("server_temp_file"));
out.writeObject(serializedObject);
out.flush();
out.close();
// copy to KM
FileInputStream in = new FileInputStream("server_temp_file");
IContent newfile = new Content(in, "application/octet-stream", -1);
// update
file.updateContent(newfile);
// close streams
in.close();
// delete temp file
File fileToDelete = new File("server_temp_file");
fileToDelete.delete();
...
Hope this can help anyone!
Thanks.
Osvaldo Silva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Osvaldo
For the purpose you can also use Configuration Adapter API available in NW 7.0/7.1. It allows to store a file in J2EE configuration repository and read it back. Here is you can find some pieces of code:
Configuration Adapter API is located in SAP-JEE/com.sap.engine.client.lib or SAP-JEE/com.sap.engine.deploy.online.
Tell me if you need additional information about the topic.
BR, Sergei
Edited by: Siarhei Pisarenka on Jul 24, 2009 10:59 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Refer this link,
http://help.sap.com/saphelp_nw04/helpdata/en/ba/78d3c747b24546ab1c1499a054d8a5/content.htm
Refer this blog,
/people/rohit.radhakrishnan/blog/2005/05/27/uploading-files-to-km-repository-using-webdynpro-apis
Regards,
Sunaina Reddy T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can obviously do that, you can create a directory in server and create a file in that directory.
Below is link for Creating A Directory On WAS Server at Desired Location and Uploading File in It Using Web Dynpro for Java.
[https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/607e9392-8167-2b10-b9a8-e0aa297e88c6?overridelayout=true]
Regards
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It is better to use KM APIs for storing file. As far as uploading files from desktop, there are stahdard UI elements in webdynpro.
Regards
Srini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.