I have some code, that in a form, a user can or can not attach an image to a request.
If the user adds the image, then I use MultipartFileData, if not, only I use HttpJob.postString
If I use HttpJob.postString, the vars in the postData are written OK in the server (By the means of correct, I refer that accents are well stored in the DB). But if I have the image, and I post the file with MultiPart (the map of data are built equal to the postData string), then the server will store with wierd chars the record. I assume that this comes from the charest used. Not sure which charset uses by standard the postString and Multipart.
If someone has this info, or how to set both of the correctly.
You can see that the word that does not encode correctly when storing the record to the DB on the server side is "ÁRBOLES"
The postData String is:
The dataMap is
If the user adds the image, then I use MultipartFileData, if not, only I use HttpJob.postString
If I use HttpJob.postString, the vars in the postData are written OK in the server (By the means of correct, I refer that accents are well stored in the DB). But if I have the image, and I post the file with MultiPart (the map of data are built equal to the postData string), then the server will store with wierd chars the record. I assume that this comes from the charest used. Not sure which charset uses by standard the postString and Multipart.
If someone has this info, or how to set both of the correctly.
B4X:
Dim jobLogin As HttpJob
jobLogin.Initialize("", Me)
If File.Exists(Main.provider.SharedFolder, "photoMail.jpg") Then
Dim images As List
images.Initialize
Dim fd As MultipartFileData
fd.Initialize
fd.KeyName = "file"
fd.Dir = Main.provider.SharedFolder
fd.FileName = "photoMail.jpg"
fd.ContentType = "image/jpg"
images.Add(fd)
jobLogin.PostMultipart(url, dataMap, images)
'jobLogin.GetRequest.SetContentEncoding("UTF-8")
jobLogin.GetRequest.Timeout=10000
Log("SEND PHOTO")
Else
Log("NO PHOTO")
jobLogin.postString(url, data)
jobLogin.GetRequest.Timeout=10000
End If
jobLogin.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0")
jobLogin.GetRequest.Timeout=10000
Wait for (jobLogin) JobDone(jobData As HttpJob)
You can see that the word that does not encode correctly when storing the record to the DB on the server side is "ÁRBOLES"
The postData String is:
B4X:
FLAG=NOTIFY.GLOBAL&idControl=1394&idPropiedad=1046&idInmueble=6138&idAcceso=0¬ificationType=mailing&rut=&nombre=&empresa=%C1RBOLES&ppu=&vehiculo=&obsEmisor=
The dataMap is
B4X:
(MyMap) {FLAG=NOTIFY.GLOBAL, idControl=1394, idPropiedad=1046, idInmueble=6138, idAcceso=0, notificationType=mailing, hasPhoto=1, rut=, nombre=, empresa=%C1RBOLES, ppu=, vehiculo=, obsEmisor=}