Skip to Content

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

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Detlev Beutner
    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
    Detlev
    (0) 
  2. Former Member
    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

    (0) 

Leave a Reply