code: public static void updateMetadata(final File file, final PropertyMap map, final boolean calcChecksums) throws FrameworkException {
  
  		final java.io.File fileOnDisk = file.getFileOnDisk(false);
  
  		if (fileOnDisk != null && fileOnDisk.exists()) {
  
  			try {
  
  				final PropertyKey<Long> fileModificationDateKey = StructrApp.key(File.class, "fileModificationDate");
  				final PropertyKey<String> contentTypeKey        = StructrApp.key(File.class, "contentType");
  				final PropertyKey<Long> sizeKey                 = StructrApp.key(File.class, "size");
  
  				String contentType = file.getContentType();
  
  				// Don't overwrite existing MIME type
  				if (StringUtils.isBlank(contentType)) {
  
  					try {
  
  						contentType = getContentMimeType(file);
  						map.put(contentTypeKey, contentType);
  
  					} catch (IOException ex) {
  						logger.debug("Unable to detect content MIME type", ex);
  					}
  				}
  
  				map.put(fileModificationDateKey, fileOnDisk.lastModified());
  
  				if (calcChecksums) {
  					map.putAll(getChecksums(file, fileOnDisk));
  				}
  
  				if (contentType != null) {
  
  					// modify type when image type is detected AND the type is "File"
  					if (contentType.startsWith("image/") && Boolean.FALSE.equals(Image.class.isAssignableFrom(file.getClass())) && File.class.getSimpleName().equals(file.getClass().getSimpleName())) {
  						map.put(AbstractNode.type, Image.class.getSimpleName());
  					}
  				}
  
  				long fileSize = FileHelper.getSize(fileOnDisk);
  				if (fileSize > 0) {
  
  					map.put(sizeKey, fileSize);
  				}
  
  				file.unlockSystemPropertiesOnce();
  				file.setProperties(file.getSecurityContext(), map);
  
  			} catch (IOException ioex) {
  				logger.warn("Unable to access {} on disk: {}", fileOnDisk, ioex.getMessage());
  			}
  		}
  	}
docs: Update checksums (optional), content type, size and additional properties of the given file
  
  @param file the file
  @param map  additional properties
  @param calcChecksums
  @throws FrameworkException