code: @Override
      public void uploadAsset(RepositoryResourceImpl resource, List<RepositoryResourceImpl> matchingResources) throws RepositoryBackendException, RepositoryResourceException {
          RepositoryResourceImpl firstMatch = (matchingResources == null || matchingResources.isEmpty()) ? null : matchingResources.get(0);
          State targetState = calculateTargetState(firstMatch);
  
          // We need to unpublish in order to overwrite
          if (firstMatch != null && firstMatch.getState() == State.PUBLISHED) {
              firstMatch.unpublish();
          }
  
          // Is this an update or an add?
          switch (resource.updateRequired(firstMatch)) {
              case ADD:
                  resource.addAsset();
                  break;
              case NOTHING:
                  if (!_forceReplace) {
                      // Use the asset from massive, although it's identical as far as we are concerned it
                      // also has the fields massive sets onto an asset when it gets uploaded, including
                      // the id itself.
                      resource.copyAsset(firstMatch);
                      break;
                  }
                  // If force replace is true then drop through to the update logic.
              case UPDATE:
                  // Partial updates don't work so copy our data into the one
                  // we found in massive and then set our asset to point to that
                  // merged asset
                  resource.overWriteAssetData(firstMatch, true);
                  resource.updateAsset();
                  break;
          }
  
          // Now iterate over the attachments
          for (AttachmentResourceImpl attachment : resource.getAttachmentImpls()) {
              uploadAttachment(resource, attachment, firstMatch);
          }
  
          // Read back from massive to get the fields massive generated into our resource
          resource.refreshFromMassive();
  
          resource.moveToState(targetState);
      }
docs: {@inheritDoc}
  
  @throws RepositoryResourceException
  @throws RepositoryBackendException