Android Question PostMultipart for Images + strings for classic ASP api

ALBRECHT

Active Member
Licensed User
Hello,

Im using PostMultipart for sending Images files and parameters strings to a server, but i have nothing into the post responses , no images, either strings?

- is it depreciated like seen here : https://www.b4x.com/android/help/appupdating.html#deprecated_multipartfiledata,
and another function is to be used : Which one ?

- or is there a mistake somewhere below ?

For information : except that, the post works and the result string 'resPOStf' return tests that i want to return ...

part of the class :
B4X:
    Dim JobUpl As HttpJob
    JobUpl.Initialize(JOBName,Me)
    Log(PSTUrl)
    
    JobUpl.PostMultipart(PSTUrl, PSTParams, Array(FileInfos))
    JobUpl.GetRequest.Timeout = 60000
    Wait For (JobUpl) JobDone(JobUpl As HttpJob)
    data = JobUpl.GetString
    JobUpl.release   
    Return data

With setting parameters and call :
B4X:
Dim Link As String = BoServerUpload ' Server URL
Dim mFileName As String = "mslogo.png"
Dim mFileTitle As String = "mslogo"
Dim Dir As String = File.DirAssets

UplParams.Put("FileName", mFileName)
UplParams.Put("Repert", "Images")
UplParams.Put("ConnGUID", UserGUID)
UplParams.Put("ProdId", 1585)
            
Dim Arqs As MultipartFileData
Arqs.Initialize       
Arqs.KeyName = mFileTitle
Arqs.Dir = Dir
Arqs.ContentType = "image/png"
Arqs.FileName = mFileName
            
Dim POStf As POSTfile 'class above
POStf.Initialize(Link, UplParams, "JobUPL", Arqs)
Wait For (POStf.SendPost) complete(resPOStf As String)        
Log(resPOStf)


Thanks
 

Brandsum

Well-Known Member
Licensed User
You can also post a file or image as a byte array (it's useful when you need to encrypt your data before posting)

B4X:
Dim cb As B4XBitmap = <yourimage>
Dim out As OutputStream
out.InitializeToBytesArray(0)
cb.WriteToStream(out, 80, "JPEG")
out.Close
Dim rawimage() As Byte = out.ToBytesArray

Dim j As HttpJob
j.Initialize("", Me)

Dim postData As Map
postData.Initialize
postData.Put("textinfo","somedata")
postData.Put("image",rawimage)

j.PostMultipart(<yourposturl>,postData,Null)
 
Last edited:
Upvote 0

ALBRECHT

Active Member
Licensed User
I have just try that way but its the same pb.

- when i post with PostString on my server page, then it receive correctly the parameters in Post methode (request.form)
- when i post with PostMultipart on the same server page then it receive nothing ?

with same data in entry, even when i send only some strings (without BytesArray either MultipartFileData)

Very annoying

is there probably a statment : ENCTYPE="multipart/..." to be set somewhere ?

Im using B4A 9.30 with OkHttpUtils2 (2.82)
 
Last edited:
Upvote 0

Brandsum

Well-Known Member
Licensed User
If you are using php then you have to use $_FIlES to get posted file and $_POST to get string data.
 
Upvote 0

ALBRECHT

Active Member
Licensed User
Ok, But my api use only the classic asp (vbscript) , which return in post method with :
B4X:
request.form("param")
perhaps do you know the equiv of that request method $_FILES in asp ?
 
Upvote 0

ALBRECHT

Active Member
Licensed User
in classical ASP : only vbscript(vb)

c# or vb.net is for ASP.NET

Im looking that for classical ASP
 
Upvote 0

ALBRECHT

Active Member
Licensed User
but the way with MultipartFileData seems to be a good manner for receiving in classic ASP
but how to send a header statement ? :
B4X:
content-type multipart/form-data
 
Upvote 0

ALBRECHT

Active Member
Licensed User
ok I will digging on the side of the Request.ServerVariables from the header ...

many thanks
 
Upvote 0

ALBRECHT

Active Member
Licensed User
RESULT = No way, with PostMultiPart

the only way for me (Using an Api in classical ASP and request.Form method)
is to send :
- with simple PostString
- and add some string charges including an image (File => Byte => Base64)

no way to do otherwise, because no "request.file" statement in ASP classic (only request.form with post method)

If someone use PostMultiPart AND Classic ASP on server side ?

Thanks BandSum
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
one of the weak parts of classic ASP was uploading files. it only worked right on small files (<1Mb?) and still with limits.

If I recall right I used aspUpload which was a 3rd party extention for IIS.

If you have full control to the server you could maybe install XAMP on a different port with root your iis upload folder and oadd a PHP upload script there.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…