code: public CmsFile writeFile(CmsRequestContext context, CmsFile resource) throws CmsException, CmsSecurityException {
  
          CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
          CmsFile result = null;
          try {
              checkOfflineProject(dbc);
              checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL);
              result = m_driverManager.writeFile(dbc, resource);
          } catch (Exception e) {
              dbc.report(null, Messages.get().container(Messages.ERR_WRITE_FILE_1, context.getSitePath(resource)), e);
          } finally {
              dbc.clear();
          }
          return result;
      }
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 context the current request context
  @param resource the resource to apply this operation to
  
  @return the written resource (may have been modified)
  
  @throws CmsSecurityException if the user has insufficient permission for the given resource ({@link CmsPermissionSet#ACCESS_WRITE} required)
  @throws CmsException if something goes wrong
  
  @see CmsObject#writeFile(CmsFile)
  @see org.opencms.file.types.I_CmsResourceType#writeFile(CmsObject, CmsSecurityManager, CmsFile)