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
4. Setcontentlength condition maxsize(in bytes)
if(prop!=null && prop.getLongIntValue()>maxsize)
5. Delete the resource if it is greater than specified value
6. Else upload the file.
ServicesReference=htmlb, usermanagement, knowledgemanagement tagLib.value=/SERVICE/htmlb/taglib/htmlb.tld
ServicesReference=htmlb, usermanagement, landscape, knowledgemanagement