title: How to use mule requester for SFTP - Dynamic file name and path
body: <p>I am trying to use a mule requester component for SFTP. How do I give the file name as part of the request argument? This is my flow:</p>
  <pre><code>&lt;flow name=&quot;Move_Doc_To_Temp_Location&quot; doc:name=&quot;Move_Doc_To_Temp_Location&quot;&gt;
      &lt;jdbc-ee:inbound-endpoint queryKey=&quot;Select_Document&quot; queryTimeout=&quot;-1&quot; pollingFrequency=&quot;30000&quot; connector-ref=&quot;LoanApp_Database&quot; doc:name=&quot;Select_Doc_To_be_moved&quot;/&gt;
      &lt;set-variable variableName=&quot;OriginalPayload&quot; value=&quot;#[payload]&quot; doc:name=&quot;OriginalPayload&quot;/&gt;
      &lt;logger message=&quot;#[payload['DocID']] - #[payload['Location']]&quot; level=&quot;INFO&quot; category=&quot;Document to be moved&quot; doc:name=&quot;Logger&quot;/&gt;
             &lt;!--  &lt;mulerequester:request config-ref=&quot;Mule_Requester&quot; resource=&quot;file:///#[payload['Location']]&quot; doc:name=&quot;Mule Requester&quot;/&gt; --&gt;
      &lt;mulerequester:request config-ref=&quot;Mule_Requester&quot; resource=&quot;sftp://user:Pwd@Hostname#[payload['Location']]&quot; doc:name=&quot;Mule Requester&quot;/&gt;  
      &lt;file:outbound-endpoint path=&quot;C:\Users\jvas\Desktop\testfiles&quot; outputPattern=&quot;#[header:originalFilename]&quot; responseTimeout=&quot;10000&quot; doc:name=&quot;File&quot;/&gt;        
  &lt;/flow&gt;
  </code></pre>
  <p>The location value resolves to /opt/Documents/test.txt. When I specify the filename like this, it throws me an error:</p>
  <blockquote>
  <p>ERROR 2014-07-24 05:51:12,358
  [[loanapp_document_flow].Move_Doc_To_Temp_Location.stage1.02]
  org.mule.exception.DefaultMessagingExceptionStrategy:
  ******************************************************************************** Message               : Failed to receive event over:
  DefaultInboundEndpoint{endpointUri=sftp://muledev:@nylicvmmuledev/opt/Documents/test.txt,
  connector=SftpConnector {   name=SFTP1   lifecycle=start   this=aa033b
  numberOfConcurrentTransactedReceivers=4<br />
  createMultipleTransactedReceivers=true   connected=true<br />
  supportedProtocols=[sftp]   serviceOverrides= } ,
  name='endpoint.sftp.nylicvmmuledev.opt.Documents.test.txt',
  mep=ONE_WAY, properties={},
  transactionConfig=Transaction{factory=null, action=INDIFFERENT,
  timeout=0}, deleteUnacceptedMessages=false, initialState=started,
  responseTimeout=10000, endpointEncoding=UTF-8,
  disableTransportTransformer=false} (timeout=1000) Code<br />
  : MULE_ERROR-92
  -------------------------------------------------------------------------------- Exception stack is:</p>
  <ol>
  <li>Error 'No such file' occurred when trying to CDW to '/opt/Documents/test.txt'. (java.io.IOException)<br />
  org.mule.transport.sftp.SftpClient:102 (null)</li>
  <li>Failed to receive event over: DefaultInboundEndpoint{endpointUri=sftp://muledev:@nylicvmmuledev/opt/Documents/test.txt,
  connector=SftpConnector {   name=SFTP1   lifecycle=start   this=aa033b
  numberOfConcurrentTransactedReceivers=4<br />
  createMultipleTransactedReceivers=true   connected=true<br />
  supportedProtocols=[sftp]   serviceOverrides= } ,
  name='endpoint.sftp.nylicvmmuledev.opt.Documents.test.txt',
  mep=ONE_WAY, properties={},
  transactionConfig=Transaction{factory=null, action=INDIFFERENT,
  timeout=0}, deleteUnacceptedMessages=false, initialState=started,
  responseTimeout=10000, endpointEncoding=UTF-8,
  disableTransportTransformer=false} (timeout=1000)
  (org.mule.api.transport.ReceiveException)<br />
  org.mule.transport.AbstractMessageRequester:132
  (<a href="http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/ReceiveException.html" rel="nofollow noreferrer">http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/ReceiveException.html</a>)
  -------------------------------------------------------------------------------- Root Exception stack trace: java.io.IOException: Error 'No such file'
  occurred when trying to CDW to '/opt/Documents/test.txt'.     at
  org.mule.transport.sftp.SftpClient.changeWorkingDirectory(SftpClient.java:102)
  at
  org.mule.transport.sftp.SftpConnector.createSftpClient(SftpConnector.java:196)
  at
  org.mule.transport.sftp.SftpConnector.createSftpClient(SftpConnector.java:174)
  <ul>
  <li>3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)</li>
  </ul>
  </li>
  </ol>
  <hr />
  </blockquote>
  <p>Now I tried removing the file name from the location, and the SFTP was successful, but it has randomly chosen a file. The file has all permissions for SFTP and I am able to do the SFTP via command line successfully. I have referred to the documentation for the SFTP URL and this is what it provides for resolving the file name from the URL : <a href="https://datatracker.ietf.org/doc/html/draft-ietf-secsh-scp-sftp-ssh-uri-04#section-4.1" rel="nofollow noreferrer">https://datatracker.ietf.org/doc/html/draft-ietf-secsh-scp-sftp-ssh-uri-04#section-4.1</a></p>
  <p>Retrieve file.txt from the user's home directory on the host at
  host.example.com using SFTP using username user.  This example
  assumes that the implementation supports the indication of a path
  relative to the home directory using a leading tilde.</p>
  <pre><code>    sftp://user@host.example.com/~/file.txt
  </code></pre>
  <p>Retrieve file.txt from the absolute path /dir/path on the host at
  host.example.com using SFTP using username user.</p>
  <pre><code>    sftp://user@host.example.com/dir/path/file.txt
  </code></pre>