NetTalk Central

Author Topic: How to take a pic and send it to a ws  (Read 8407 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
How to take a pic and send it to a ws
« on: July 02, 2019, 03:39:50 AM »
Hi, having a Sqlite table in the phone, I need to take a picture for each record, save it on the phone and when connected, send the records and each picture to a web server.
Any idea of how to do it?
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: How to take a pic and send it to a ws
« Reply #1 on: July 02, 2019, 04:56:43 AM »
Hi Alberto,

>> Having a Sqlite table in the phone,

SQLite? I'm not sure how that's in play here.
Web apps use IndexedDB, not SQLLite.

>>  I need to take a picture for each record, save it on the phone and when connected, send the records and each picture to a web server.  Any idea of how to do it?

At the moment only a hazy idea. It's something I'm looking into for my own use as well, but I haven't got a method yet. (I'm wanting to do more than just an image, I'm hoping to do video and audio as well, but I'm not sure if it's possible yet.

Cheers
Bruce

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: How to take a pic and send it to a ws
« Reply #2 on: July 05, 2019, 06:51:48 AM »
Hi, having a Sqlite table in the phone, I need to take a picture for each record, save it on the phone and when connected, send the records and each picture to a web server.
Any idea of how to do it?

Hi Alberto:
  Want to send the picture to a web service (rest or soap?) or web server?

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to take a pic and send it to a ws
« Reply #3 on: July 05, 2019, 06:56:17 AM »
Hi, having a Sqlite table in the phone, I need to take a picture for each record, save it on the phone and when connected, send the records and each picture to a web server.
Any idea of how to do it?

Hi Alberto:
  Want to send the picture to a web service (rest or soap?) or web server?

Soap, web service made with NT
-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to take a pic and send it to a ws
« Reply #4 on: July 05, 2019, 07:03:04 AM »
Bruce,

Ive made an app using Basic4Android, native app fro Android... (xcelente, by the way...)
This app uses Sqlite to store a table with some fields and a blob for a image.
The app connects to a NT WebService, Soaop, no matter XML or Json is the same, and downloads a list of Adresses for the user to be visited and stores it in the Sqlite table.
The user goes away, disconnected from the web... it takes pictures from the Adrresses of the list.
The pictures are stored in the blob of the Sqlite record.
Onces the user is back and connected it need to send the pictures to the NT WS for it to be saved in the NT blob database.
How to send te Sqlite blob field to the NT WS in xml or json?

PD: Now Im sending the images to a PHP server, mi need is to get rid of the PHP server and if I cant send the images via Soap/Blob then, may be, theres a way to send the images to the NT server... using FTP?

« Last Edit: July 06, 2019, 10:07:32 AM by michelis »
-----------
Regards
Alberto

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: How to take a pic and send it to a ws
« Reply #5 on: July 06, 2019, 09:10:32 AM »
This may or may not be helpful but check this out:


Capturing Audio & Video in HTML5
https://www.html5rocks.com/en/tutorials/getusermedia/intro/

I'm almost positive Bruce is using some of these techniques in NT already.

Anyway, interesting topic indeed.

Alberto, if you get this running, please update us here!  Thank you!

Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: How to take a pic and send it to a ws
« Reply #6 on: July 07, 2019, 09:39:33 PM »
Hi Alberto,

thanks for the context - that makes the question easier to answer.

>> How to send te Sqlite blob field to the NT WS in xml or json?

Basically in the XML or JSON it will be a "field" just like any other, except that you will need to Base64 encode the contents of the field before sending it. In other words it arrives at the server as a base64 encoded string.
[Aside: If the post was done as a www-form-encoded format then the BLOB would not be encoded.]

On the server side you can store it base64 encoded if you like, or you can base64 decode it and store it as base64 decoded.

On the server side the "parameter" you need depends a bit on how you are doing things. Either it's just a BLOB field in a table, or you can make it a separate parameter of type StringTheory (or FILE) if you like. (Don't confuse FILE with TABLE). the only dofference between FILE and STRINGTHEORY as I recall is that FILE is base64 decoded for you (if it arrives as JSON or XML).

Cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to take a pic and send it to a ws
« Reply #7 on: July 08, 2019, 05:35:27 AM »
>>> On the server side the "parameter" you need depends a bit on how you are doing things. Either it's just a BLOB field in a table, or you can make it a separate parameter of type StringTheory (or FILE) if you like. (Don't confuse FILE with TABLE). the only dofference between FILE and STRINGTHEORY as I recall is that FILE is base64 decoded for you (if it arrives as JSON or XML).

Thanks Bruce I did it!
Im receiving the b64 in a st object and use st functions to save it to the blob field.

How to use the Errortrap method to get the error? Theres no any example in the docs.

Any way to know if st value is base64 coded?

« Last Edit: July 08, 2019, 05:35:07 PM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: How to take a pic and send it to a ws
« Reply #8 on: July 09, 2019, 02:14:46 AM »
>> Any way to know if st value is base64 coded?

if you call st.base64encode() then the property
st.base64 property is set to true.
Obviously that's not really helpful though if you "get some text" and want to figure out if it's "base64".

The short answer is that there's no way to be sure that something is base64 encoded.
I mean the string
abcdef qualifies as being "something base 64 encoded" but it also qualifies as being a "plain string".

It's probably possible to determine that something "is not base64" - but that test would only return "is not base64" or "maybe base 64".

>> How to use the Errortrap method to get the error?

StringTheory ErrorTrap, or NetTalk ErrorTrap?

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to take a pic and send it to a ws
« Reply #9 on: July 09, 2019, 08:25:06 AM »
ST ErrorTrap, suppouse Im doing a

if not ST.LoadFile('xxxx.xxx')
   message('error')
end

How to use ErrorTrap to know which error?
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: How to take a pic and send it to a ws
« Reply #10 on: July 09, 2019, 09:55:51 PM »
To add code to ErrorTrap (or any StringTheory method) you need to declare the object as a class.
For example

st   Class(StringTheory)
ErrorTrap             Procedure (string methodName, string errorMessage), virtual
     end

You can lift the method declaration (ie the ErrorTrap line) from stringtheory.inc

Then at the bottom of your procedure add;

st.ErrorTrap          Procedure (string methodName, string errorMessage)
  code
  message('error')

This might be somewhat overkill though for what you actually want to do. Your original code might be better written as;

if not ST.LoadFile('xxxx.xxx')
   message('error ' & st.Errorcode & '  ' & st.LastError & ' ' & st.winErrorCode & ' ' & st.FormatMessage(st.WinErrorCode))
end


As always it's probably a good idea to check out the code for ErrorTrap, and LoadFile in StringTheory.clw so you can see what is going on.

Cheers
Bruce