Android Question posting to a WebFTP client

Dion Balson

New Member
Licensed User
Longtime User
Hello,

I am trying to upload files to a html based "FTP" client, i put ftp in brackets as it has nothing to do with ftp and this is just what are calling it. I have not done very much with web based requests and don't really know where to start with this one.

the web service is called synaman and is offered by synametrics
http://web.synametrics.com/SynaMan.htm

it requires a secure login and then you need to upload files one at a time from a javascript based file browser.

so what i need to do is authenticate and then upload the new files to the server. I am feeling very stupid as I am unable to figure this out.

B4X:
Sub Globals
    Dim job1 As HttpJob
    Dim job2 As HttpJob
 
    job1.Initialize("Job1",Me)
    job2.initialize("Job2",Me)  
    End Sub
 
Sub Activity_Create(FirstTime As Boolean)
 
End Sub
 
Sub Activity_Resume
 
    job1.PostString("server","uid=user&pwd=pass")
 
End Sub
 
Sub Activity_Pause (UserClosed As Boolean)
 
End Sub
 
Sub jobdone (job As HttpJob)
    Dim namer As String = job.JobName
    If job.Success = True Then
        If job.JobName="Job1" Then
                job2.PostFile("server?operation=up",File.DirRootExternal , "WTRCRINP.WCC")
        End If
      
        If job.JobName="Job2" Then
                job1.Release
                job2.Release
                Activity.Finish
        End If
    Else
        ToastMessageShow(job.ErrorMessage,True)
    End If
  
End Sub

Thank You.
 
Last edited:

Dion Balson

New Member
Licensed User
Longtime User
I had looked at the requests as I am logging in an uploading a file and tried to simulate the post requests.

it is a secure connection (https) and i am curious how do i carry my session id from the login request to the upload request.
 
Upvote 0

Dion Balson

New Member
Licensed User
Longtime User
The server says that I am logging in correctly but the file I am trying to upload is not showing up on the server.

Here is the XML from a upload request generated on the server. I am having issues figuring out the postfile command that would correspond.

I have tried

B4X:
job2.postfile("https://webftp.mcelhanney.net/app?operation=up", File.DirRootExternal , "test.jpg")

B4X:
- <request>
<method>POST</method>
<url>https://webftp.mcelhanney.net/app?operation=up</url>
<httpVersion>HTTP/1.1</httpVersion>
- <cookies>
- <cookie>
<name>JSESSIONID</name>
<value>EC0F8749E7A932EDDC1CF9A92F0F51D0</value>
</cookie>
</cookies>
- <headers>
- <header>
<name>Accept</name>
<value>text/html, application/xhtml+xml, */*</value>
</header>
- <header>
<name>Referer</name>
<value>https://webftp.mcelhanney.net/app</value>
</header>
- <header>
<name>Accept-Language</name>
<value>en-US</value>
</header>
- <header>
<name>User-Agent</name>
<value>Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)</value>
</header>
- <header>
<name>Content-Type</name>
<value>multipart/form-data; boundary=---------------------------7de3322a730cc2</value>
</header>
- <header>
<name>Accept-Encoding</name>
<value>gzip, deflate</value>
</header>
- <header>
<name>Host</name>
<value>webftp.mcelhanney.net</value>
</header>
- <header>
<name>Content-Length</name>
<value>348378</value>
</header>
- <header>
<name>Connection</name>
<value>Keep-Alive</value>
</header>
- <header>
<name>Cache-Control</name>
<value>no-cache</value>
</header>
- <header>
<name>Cookie</name>
<value>JSESSIONID=EC0F8749E7A932EDDC1CF9A92F0F51D0</value>
</header>
</headers>
- <queryString>
- <param>
<name>operation</name>
<value>up</value>
</param>
</queryString>
- <postData>
<mimeType>multipart/form-data</mimeType>
- <params>
- <param>
<name>uploadFormElement</name>
<filename>Database1.accdb</filename>
<contentType>application/msaccess</contentType>
</param>
</params>
</postData>
<headersSize>508</headersSize>
<bodySize>348378</bodySize>
</request>
 
Upvote 0

Dion Balson

New Member
Licensed User
Longtime User
Great Thank you, I have added the multipart post to the HttpJob class and configured it to match the multipart post that is being generated on my PC.
my only issue now is that I need to send the Content-Length along wih the POST.
"SynaMan uses HTTP POST to upload file from a client machine. HTTP POST requires the content-length be provided before posting."
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…