Quantcast
Channel: SCN : Popular Discussions - SAP Enterprise Portal: Content Management and Collaboration
Viewing all articles
Browse latest Browse all 1826

Upload a file(Size in MB's) in KM

$
0
0

Dear Experts,

 

I have created an application that allows users to upload a file in KM but the application does not work if the file's size is big(in MB's).

 

Kindly find the code below:

 

JSP File Code:

<html>

<head>

<title>

File Upload in KM

</title>

</head>

<body>

<div style="position:absolute;border: 1px #3063A5 solid;">

<table border="0" width="100%" style="background-color:#3063A5;">

<tr>

<td height = "25px" width="100%" align = "left">

<marquee><font color=#FFFFFF style="font-weight: bold; font-family: verdana; font-size:75%;vertical-align: 50%;"> File Upload</font> </marquee>

</td>

</tr>

</table>

<form name="logonForm" method="post" ENCTYPE="multipart/form-data" target="_parent" action="/FileUploadtoKM/FileUploadtoKM">

<div style="background-color:#CAE1FF;">

<table align="center" style="background-color:#CAE1FF;">

<tr>

<td>

<font style='color:BLACK;font-size:12pt;font-style:Verdana;font-weight:bold'>Select a file:</font> </td>

<td>

<input type="file" name="upload_file" size="25" value="">

</td>

</tr>

<tr>

<td></td>

<td align="left">

<input type="submit" name="Submit" value="Submit" />

</td>

</tr>

</form>

</div>

</body>

</html>

 

FileUploadtoKM Servlet Code:

 

//     Create a MultipartRequest to parse multipart/form-data

  MultipartRequest multi = new MultipartRequest(request,".");

//     Get the name of the uploaded file

  String strFileName = multi.getFilesystemName("upload_file");

//     Get the mime type of the uploaded file

  String strMimeType = multi.getContentType("upload_file");

//     Create a FileInputStream from the Uplaoded file

  FileInputStream sourceFileInput = new FileInputStream(strFileName);

  Content content = new Content(sourceFileInput,strMimeType,-1L);

//    Create a Resource Context with the service user - cmadmin_service

  ResourceContext ctx = new ResourceContext(WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service"));

//    RID of folder where the documents are uploaded

  RID rid = RID.getRID("/documents/Disha/");

  IResource resource = ResourceFactory.getInstance().getResource(rid,ctx);

  ICollection collection = (ICollection) resource;

//     Create the resource in KM

  IResource newResource = collection.createResource(strFileName,null,content);

      

  RequestDispatcher rd = null;

  rd= request.getRequestDispatcher("/JSP/Success.jsp");

  rd.forward(request,response);

 

 

Any help would be highly appreciated.

 

Thank you,

 

Regards,

Disha.


Viewing all articles
Browse latest Browse all 1826

Trending Articles