title: Fast Api passing local file location to function to be upload to a server
body: <p>I am making an endpoint with a fast API to upload multiple files in a single request.</p>
  <p>To get multiple files use this.</p>
  <pre><code>   files: List[UploadFile] = File(...),
  </code></pre>
  <p>And i have another function that is responsible for uploading the files to an sftp:</p>
  <pre><code>    def save_to_sftp(self, file) -&gt; str:
          hostname = &quot;0.0.0.0&quot;
          username = &quot;foo&quot;
          password = &quot;pass&quot;
  
          localfile = &quot;/home/UserName/&quot; + file.filename
          remotefile = &quot;root/&quot; + file.filename
  
          try:
              transport = paramiko.Transport(hostname, 22)
              transport.connect(username=username, password=password)
              sftp = paramiko.SFTPClient.from_transport(transport)
  
              sftp.put(localpath=localfile, remotepath=remotefile)
              sftp.close()
              transport.close()
              return file.filename
          except Exception as err:
              raise ValueError(err)
  
  </code></pre>
  <p>Now to upload the files to sftp I need the location of the file that will go to the server but until now I don't understand how I can do that.</p>
  <p>I would like any suggestions on how I can send the local file location to my script or any suggestions on how I can get the files uploaded.</p>
  <p>Thanks</p>