Load & Retrieve Images into/from DB by REST service


#1

Hi all gurus. I’ve a Web App using REST services, using peoples stored in SQLServer along with their photos. I’d like to manage Android & iOs mobile devices to catch and/or receive photos, say, w/WhatsApp and have them stored in the DB w/my app. I can successfully retrieve & display them in a PictureBox, but how2 store a new image? Can Y pls drive me to this goal? Is there a sample and/or tutorial? (As of now I manage them with a Silverlight app from a Pc, but it’s time to move to mobiles), TIA


#2

Have a look at this Tech Note:
http://wiki.nsbasic.com/Ajax_made_Simple

See #14.


#3

Thank you. Following your suggestion I’ve built some code. However, it leads to an error 404 trying to submit the REST command. I can see what I receive on the server side in the “foto” parameter, and it’s NOT a string, nor I can convert it from Base64, and it throws the given error.

txtFile2Load is a textBox in “File” mode
PictureBox4 is a PictureBox
btnLoadImg is a Button (to make the send op)
lblRespAgg is a label

Function txtFile2Load_onchange()
  reader.readAsDataURL(txtFile2Load.files[0])
  e=event
End Function

Function reader_onload(e)
  img.src=e.target.result
  PictureBox4.src=e.target.result 'Phone Viewing ONLY
  btnLoadImg.hidden=False
End Function

Function btnLoadImg_onclick()
  btnLoadImg.hidden=True
  txtFile2Load.hidden=True
  Dim foto=PictureBox4.toDataURL
  Dim fotolen=foto.length
  URL="http://"+txtSvr.value+"/RestSvc4Gescom/UpdateDati.svc/insertfoto/?uid="+txtUserId.value+"&pwd="+txtPassword.value+"&coda="+coda+"&foto="+foto
  encURL=encodeURI(URL)
  req=Ajax(encURL,"POST","")
  If req.status=200 Then
      lblRespAgg.textContent=req.responseText
      btnAggiorna.disabled=True
  Else
      lblRespAgg.textContent="Errore "+req.status
  End If
End Function

#4

this is what I see watching internal REST service call


Image data base
#5

Since I’ve achieved most goals but one, I’m gon’ to post another request for narrowing code, and set an answer to this. Should Y like, have a look @ “Passing long parameters to REST service avoinding 414 error”


Passing long parameters to REST service avoiding 414 error