NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Alberto 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?
-
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
-
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?
-
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
-
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?
-
This may or may not be helpful but check this out:
Capturing Audio & Video in HTML5
https://www.html5rocks.com/en/tutorials/getusermedia/intro/ (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
-
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
-
>>> 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?
-
>> 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
-
ST ErrorTrap, suppouse Im doing a
if not ST.LoadFile('xxxx.xxx')
message('error')
end
How to use ErrorTrap to know which error?
-
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