code: public CmsFile writeFile(CmsDbContext dbc, CmsFile resource) throws CmsException {
  
          resource.setUserLastModified(dbc.currentUser().getId());
          resource.setContents(resource.getContents()); // to be sure the content date is updated
  
          getVfsDriver(dbc).writeResource(dbc, dbc.currentProject().getUuid(), resource, UPDATE_RESOURCE_STATE);
  
          byte[] contents = resource.getContents();
          getVfsDriver(dbc).writeContent(dbc, resource.getResourceId(), contents);
          // log it
          log(
              dbc,
              new CmsLogEntry(
                  dbc,
                  resource.getStructureId(),
                  CmsLogEntryType.RESOURCE_CONTENT_MODIFIED,
                  new String[] {resource.getRootPath()}),
              false);
  
          // read the file back from db
          resource = new CmsFile(readResource(dbc, resource.getStructureId(), CmsResourceFilter.ALL));
          resource.setContents(contents);
  
          deleteRelationsWithSiblings(dbc, resource);
  
          // update the cache
          m_monitor.clearResourceCache();
  
          Map<String, Object> data = new HashMap<String, Object>(2);
          data.put(I_CmsEventListener.KEY_RESOURCE, resource);
          data.put(I_CmsEventListener.KEY_CHANGE, new Integer(CHANGED_CONTENT));
          OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_RESOURCE_MODIFIED, data));
  
          return resource;
      }
docs: Writes a resource to the OpenCms VFS, including it's content.<p>
  
  Applies only to resources of type <code>{@link CmsFile}</code>
  i.e. resources that have a binary content attached.<p>
  
  Certain resource types might apply content validation or transformation rules
  before the resource is actually written to the VFS. The returned result
  might therefore be a modified version from the provided original.<p>
  
  @param dbc the current database context
  @param resource the resource to apply this operation to
  
  @return the written resource (may have been modified)
  
  @throws CmsException if something goes wrong
  
  @see CmsObject#writeFile(CmsFile)
  @see I_CmsResourceType#writeFile(CmsObject, CmsSecurityManager, CmsFile)