docstr: uploads file to xnat using REST API
docstr_tok: ["uploads","file","to","xnat","using","REST","API"]
code: def _request_put_file(
      self, experiment, scan, file2send, name_at_xnat, ai_model_name
  ):
      """
      uploads file to xnat using REST API
      """
      folder = "AI"
      url = "{}/REST/experiments/{}/scans/{}/resources/{}/files/{}".format(
          self.api_url,
          quote_plus(experiment),
          quote_plus(scan),
          quote_plus(folder),
          quote_plus(name_at_xnat),
      )
      data = open(file2send, "rb")
      params = {
          "overwrite": "true",
          "description": name_at_xnat,
          "content": ai_model_name,
          "format": "nii",
      }
      response = self.xnat_session.put(
          url,
          params=params,
          data=data,
          headers={"Content-Type": "application/octet-stream"},
          allow_redirects=True,
      )
      if response.status_code != 200:  # failed call
          logger.error(
              f" put call error status_code= {response.status_code}  text ={response.text}"
          )
      else:
          logger.info(f" put completed {response.text}")
  
      return response
  
imports: import io
  import logging
  import os
  import pathlib
  import shutil
  import time
  from typing import Any, Dict, List, Optional
  from urllib.parse import quote_plus
  from xml.etree import ElementTree
  import requests
  from requests.auth import HTTPBasicAuth
  from monailabel.datastore.utils.convert import nifti_to_dicom_seg
  from monailabel.interfaces.datastore import Datastore
  from monailabel.utils.others.generic import md5_digest
label_desc: Use image node_id 37 for calling the XNATDatastore obj's underlying member method code with example usage: obj._request_put_file(experiment, scan, file2send, name_at_xnat, ai_model_name) and returns: response