B4J Question Upload files from your B4J app to your B4J server over the internet

cklester

Active Member
Licensed User
For my app, the client has a local KVS. I want to upload the KVS and store it on the server, so it looks like the proper way is to B4XSerializator the KVS and send it up.

The serialized KVS will be stored in a MySQL database (already set up and functioning properly).

Is there a sample client code module similar to [Server] Upload files from your B4A app to your B4J server over the internet but for a B4J client? I don't have B4A at the moment.

I did a search for "b4j file client," which did not seem to have any relevant code, and B4XSerializator, which had a ton of results, none of which I could determine were relevant (but I'm sure there are some relevant hits there--I just don't know what to look for.)

(If anyone wants to suggest an alternate/better approach, I'm all ears!)
 

cklester

Active Member
Licensed User
Which type of server?

Oops. It's a B4J server*, based, IIRC, on [Server] Login System & Filters Tutorial.

I might try to migrate to @aeric 's User Login + MySQL B4J API (API Key + Token), which looks amazing, but I'm on a roll right now with what I started with, and I'll have to make a few mods to get his system up and running locally. (No biggie. Just have momentum already...) 😁

No reason to use B4XSerializator. Zip the database files (kvs = database) and upload the zip.

Ah. OK. So, on the client, I would need to ZIP the KVS to a separate file then upload it with a BinaryStream (?). Can you show me or point me to a sample B4J client upload binary code?

Thank you!

*You should have known this, @Erel . Why would I use anything else?! 😁
 
Upvote 0

aeric

Expert
Licensed User
I referenced that thread in my first post here. I don't have B4A. (I'll get it eventually, just not needed yet.) So, is there a B4J version of that client? I guess I can view the code in a text editor anyway... but it would be nice to have a B4J client. 😁
B4A is free. Why not try and use it? If you have no Android device, you can try whether the emulator works for you. Btw, I am trying to port my B4A client to B4J and it seems not so straight forward for me especially the UI. Maybe I am more familiar with B4A.
 
Upvote 0

cklester

Active Member
Licensed User
B4A is free. Why not try and use it? If you have no Android device, you can try whether the emulator works for you. Btw, I am trying to port my B4A client to B4J and it seems not so straight forward for me especially the UI. Maybe I am more familiar with B4A.

OK, I'll load up B4A and see what I can do.
 
Upvote 0

cklester

Active Member
Licensed User
OK, I set up B4A. I didn't have to install a ton of extra, resource-heavy stuff.

B4A plus the B4A-Bridge. I'm making Android apps!

I've got the B4A client and B4J server working together to pass text and files. Now to do that with a B4J client!

This is stupid easy. 😍 Erel should be a billionaire. 😁
 
Upvote 0

aeric

Expert
Licensed User
Btw, I am trying to port my B4A client to B4J and it seems not so straight forward for me especially the UI.
Hope I can share my B4J client (B4XPages) when ready. Or you are interested with my half-bake sample? 😄
 
Upvote 0

aeric

Expert
Licensed User
By the way, your title should be "Update data from your B4J app to your B4J server over the internet"
 
Upvote 0

cklester

Active Member
Licensed User
By the way, your title should be "Update data from your B4J app to your B4J server over the internet"

Well, I'm actually trying to upload a KVS file. I'm probably going to take Erel's suggestion and Zip it up and upload it to the server. What's your thinking in that regard?
 
Upvote 0

aeric

Expert
Licensed User
Well, I'm actually trying to upload a KVS file. I'm probably going to take Erel's suggestion and Zip it up and upload it to the server. What's your thinking in that regard?
If you upload the KVS file, how do you update the MySQL database?
 
Upvote 0

aeric

Expert
Licensed User
I'm putting the file as a blob in the database. Yes, with an UPDATE, but I think I can do that.
But my sample doesn't upload any file into remote MySQL database.
 
Upvote 0

cklester

Active Member
Licensed User
But my sample doesn't upload any file into remote MySQL database.

@aeric You're right! I think I got confused as to which topic I was on... Sorry about that.

Your sample uploads a file, right? Once I have the file uploaded, I'll just dump it into my database. Are you saying I could skip the "save file" step and put the data directly into the database? That would probably be optimal.

I guess I could InputStream it to a Byte() and put that in the MySQL DB, right?
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Are you saying I could skip the "save file" step and put the data directly into the database?
Yes, I guess you only want the values right? I don't get the point to store the KVS files into database. Unless it is image file.
If you only want to add new data to MySQL table then you can use SQL query to insert the data.
 
Upvote 0

cklester

Active Member
Licensed User
On the client, I'm using a KVS. That way they can work with it locally and offline. When it's time to save it, I will just upload that and store it in a MySQL database as a BLOB. I will probably convert everything to work directly to a MySQL database at some point, if it becomes necessary or desirable. For now, this seemed like a quick and easy solution.

This is all happening via an API.
 
Upvote 0
Top