Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

Summary

One of the major problems in Content Management is restricting the size of the file to be upload in CM repository. In this blog I had come up with a solution in which u can restrict the size of the file based on your requirement.

The steps for restricting the upload, followed in the code are as follows:

1. Create the resource

aResource = aCollection.createResource(this.resource, this.propertyMap, aContent);

2. Create property object

IProperty prop = null;

3. Get the property using property name

prop=aResource.getProperty(PropertyName.createContentLength());

4. Setcontentlength condition maxsize(in bytes)

if(prop!=null && prop.getLongIntValue()>maxsize)

5. Delete the resource if it is greater than specified value

aResource.delete();

6. Else upload the file.

CODE:

Default.properties:

ClassName=com.sap.sdn.codesamples.upload.UploadIview

ServicesReference=htmlb, usermanagement, knowledgemanagement tagLib.value=/SERVICE/htmlb/taglib/htmlb.tld

UploadIview.properties:

ServicesReference=htmlb, usermanagement, landscape, knowledgemanagement

ClassName=com.sap.sdn.codesamples.upload.UploadIview tagLib.value=/SERVICE/htmlb/taglib/htmlb.tld

2 Comments