• Get a documents size

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #30375  by holgrich
 
Hi all,

in Java, I would like to get a document's physical size (like "2032 KB"). Is this possible using the current version of the API? I tried
Code: Select all
ws.getDocumentProperties( x["uuid"] )
but this doesn't contain the size...

Regards
Holger
 #30392  by jllort
 
From the object Document you get ActualVersion and there's the document size as a number, to convert on human format can do something like
Code: Select all
private static final String[] UNITS = new String[] { "B", "KB", "MB", "GB", "TB", "PB", "EB" };

/**
	 * Format the document size for human readers
	 */
	public static String formatSize(long bytes) {
		for (int i = 6; i > 0; i--) {
			double step = Math.pow(1024, i);
			if (bytes > step)
				return String.format(Locale.ROOT, "%3.1f %s", bytes / step, UNITS[i]);
		}
		
		return Long.toString(bytes) + " " + UNITS[0];
	}
 #31122  by amber14
 
How shoud I send the params?
An example would be really appreciated. Not necessarily related to Delphi, just the params
Thanks in advance.
Marcelo.
 #31136  by jllort
 
if you call getProperties ( api ) -> into you got variable called actualVersion -> what contains the document size as a number. Should be something like:
Code: Select all
long size = ws.getProperties(token, docPath).getActualVersion().getSize();
You can not sent the size parameter, you only can get the stored value. When you change document version, the value is automatically changed.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.