Binary multipart upload by HTTP POST to web service

bluedude

Well-Known Member
Licensed User
Longtime User
I have a simple idea but i'm not sure how to code it. I want an image captured by the camera uploaded by HTTP to a web service.

Anyone any ideas on how to do this? The image should be uploaded binary.
 

Aspire89

Member
Licensed User
I don't have an account so I get an 'unknown user' error.
Tell me how it went.

Thanks, good example.
I have an account on this site and tried how it works. In response, I receive an error:

<? xml version = "1.0" encoding = "UTF-8"?>
<rsp stat="fail">
<err Code="1002" msg="Image not found" />
</ rsp>


The path to the file checked, all OK.
Then he looked at his request in HttpAnalizer. Although the method is POST, and POST data is empty, and the username and password into the stream.
 

Aspire89

Member
Licensed User
I used the following code:

B4X:
    request.New1("http://tweeterwall.mallplace.com/tw/vote")
    request.Method = "POST"
    request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.1) Gecko/20090715 MRA 5.3 (build 02560) Firefox/3.5.1 (.NET CLR 3.5.30729)"    
    Request.ContentType = "text/javascript"
    stream.New1(Request.GetStream,False) 
    name = "uid=27024&country_id=68&token=049226fb46577eb02790105aae66dc1e"
    stream.WriteBytes(stream.StringToBytes(name))
    response.New1
    request.GetAsyncResponse
and HttpAnalizer received the following (details in the screenshot)
 

bluedude

Well-Known Member
Licensed User
Longtime User
Problem too

Hi Erel,

First let me say that you are very quick in replies etc! You do a great job running this forum and software.

The multipart post solution for Twipic does not work for me, same problem as the other user.

What i'm basically looking for is a generic sample that combines posting fields and a file in one call. Im working on a product that can talk to a whole bunch of web services (POST) and this binary upload stuff frustrates me.

For some services i write my own small PHP wrappers to make it easier but the uploading stuff in combination with input fields I cannot get to run.

This sample has a lot of stuff I don't understand (boundary).

Hope you have a generic sample and maybe even better with Async stuff.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Understood

Ok, that is understood.

Need to figure out how to do it in BASIC4PPC. Posting data is simple but not sure how to combine file and input fields.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Multipart upload

Erel,

This multipart stuff is killing me, there are so many projects where you need HTTP upload to create interesting applications.

Here is s simpler sample in VB: Sample Visual Basic Examples by Conor Hackett - TweetPhoto Developers | Google Groups

Has anyone solved this in the end?

Is there anyone who has time to develop a dll for this? I think a generic multipart upload dll would be awesome.

Without it we are very limited regarding file operations, FTP is not really an option because none of these web services support FTP.

Any help is appreciated, i'm even prepared to pay for it!!!
 

TWELVE

Active Member
Licensed User
I can help out here, had the same issue with the POST multipart, after some intense network tracing, comparing and reading a couple of RFCs i finally got it to work.

I will post example code here soon, once i've tested everything...


regards,

TWELVE
 

a6000000

Member
Licensed User
Longtime User
Please can anyone post how to find the last Picture from camera to upload?
[EDIT] find: http://www.b4x.com/forum/code-sampl...e-using-internal-camera-your-application.html [/EDIT]

BUT: to send a binary file-stream (picture) , for send over HTTP-POST works
'// ( no more problems with PUT -the samples here I do not bring to work)
when I convert it to ascii - I convert it to longer stream , and ONLY USE PRINTABLE chars
(I was inspirated by JSON ) and tested til 2Megabyte Pictures on desktop , now I will try on my ppc .
in the web I reconvert the POST to binary with php.

:cool:
 
Last edited:
Top