on 10-08-2009 2:20 PM
Hi Frnds,
Can u help me how to Downlod file from KM using NWDS, i'v tryed with Tutorial but its with mime types only i want get it from KM and i need in detail with sample code, i need to do sooner.
please Hope u can help me.
ThanQ
vita.
Hi,
try {
//create an user object from the current user
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
//create an ep5 user from the retrieved user
com.sapportals.portal.security.usermanagement.IUser ep5User =
WPUMFactory.getUserFactory().getEP5User(sapUser);
ResourceContext context = new ResourceContext(ep5User);
//Give the path to KM in the variable path
String path = "<KM_file_path>"; // ex. /documents/test.txt
RID rid = RID.getRID(path);
IResourceFactory factory = ResourceFactory.getInstance();
IResource resource = factory.getResource(rid, context);
IContent content = resource.getContent();
InputStream IStream = content.getInputStream();
.......
..........
} catch (Exception e) {
msgMgr.reportException(e.getMessage(),true);
}
Regards
Matteo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if you use a FileDownloadUI Element you can add this code:
.......
InputStream IStream = content.getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
//out is to store the content of the file from KM
byte[] buffer = new byte[4096];
int bytesread = 0;
while ((bytesread = IStream.read(buffer)) != -1) {
out.write(buffer, 0, bytesread);
}
IWDResource res = WDResourceFactory.createResource(out.toByteArray(),
resource.getName(),
WDWebResourceType.getWebResourceTypeForFileExtension(resource.getResourceType()));
wdContext.currentContextElement().setResource(res); // context attribute bind to FileDownload
Regards
Matteo
Thank Metto,
Thanks for Reply am happy with Ur code but can u explan bit in details b4 writting the code like do i go with ActionLink, Filedownlod or with Button UI, can u explan for me step bu step plz so that i can finesh my task, itrs very kind of u if u can
i hope u do reply soon.
ThanQ
vita.
Hi vita,
1. use the FileDownloadUI element and put it in a view
2. bind the property resource of the FileDownloadUI with an attribute of the context of type Resource (Dictionary simple type: com.sap.ide.webdynpro.uielementdefinitions.Resource)
3. before the view is shown on the screen execute the code posted to load the file in the context. For example put the code in wdDoInit() method or in a onPlugIn method of the view.
So the user can download the file
Regards
Matteo
ThanQ For Time Sir,
Its very kind u given for me.
I did as u said every thing is fine now, but when open a File its opeing in Unknow type not in Pdf ro Exesting Format.
i have few Req...nts
1) user need to get Pop Save, Open and Cancel but hear i'm getting only Save and cancel.
2) according my Req.. user get one window with list of KM Files so that he can Click or Get download any of the file wich is in KM.
hope u get it
Plz Reply me Soon .
Thaks Lot
ThanQ,
vita,
Thanks Dear,
With that link i can able to access KM Browser, that is great.
But that is only accessing the DIR's i need to open the file. when am giving the root path according 2 above link as u explaind am able C my all files which is execting in my KM Folder but when i click on it it is not opening through browser can give this small tip plz .
it would be very kind of u Dear.
ThanQ n Regards,
vita.
Hi Dear,
i have small task but bit draging me... i hope some one can help me out from this.
i am developting one application in wedbynpro with in NWDS with EP7.0 sp14, the devloping application is file Uploding which is am completed but with that file upload i have few parametars(InputFields) need store in KM folder with uploading file,
Like: File Name, File ID, FileDate, File Description like that i have nearly 5 input fields b4 selecting a file from browser user need to enter these input fileds then selcet a file for upload then user can click upload button .
Once user click onbutton the file is uploading sucssessfully in KM @docs/userfolder/ , but problem is am able to upload only file wich is selected through broweser not values which i'v enterd in Inputfield, wht to do get this values in KM plz provide some sample codes.
Plz can u help its very urjent.
ThanQ & Regards,
Vita.
User | Count |
---|---|
85 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.