Skip to Content

Restricting The Size Of The File To Be Upload in CM Repository


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 tagLib.value=/SERVICE/htmlb/taglib/htmlb.tld

You must be Logged on to comment or reply to a post.
  • Hi,
    the provided code suffers from some disadvantages:
    (a) Even if one would use this AbstractPortalComponent, the implementation has the disadvantage that a resource in fact gets created and deleted again – but with such an individual development, you could check the size of the file before the resource gets created (and, for example, repository service implementations are called which have registered for this event; the same holds for the deletion).
    (b) In real life, one would need a command implementation which can be used and configured from within FlexUI. In fact, this can be done by calling a standard portal component implementations, as for example to be seen on XML Forms creation. So the implementation could rest within the component created, you just would have to develop an additional command which then calls the component within a new window.
    (c) Anyhow, people are used to use the standard upload command offered with KM – and it’s additional features. So the main task would be to restrict the upload size using this command (or a modification of it); see /thread/80571 [original link is broken] as well as in the links provided there for a discussion of this problem and possible workarounds. Anyhow, the result of this discussion is: There is no “smooth” way to reach this aim.
    Hope it helps
  • Hi,

        Kindly plz suggest a clear picture regarding restricting folder size to be uploaded.

    I mean more ellaborated solution in doing this from scratch.

    Thanks and Regards
    Santosh Saraf