Error when exporting saved photos in SQLite to Mysql remote server

Hi All,

In my project I save photos from camera or from gallery in a SQLite local database and after this I am sending them to a MySQL remote database. I need to compress those images to send to remote server, so I decided to make this compression (and transform into base64 data) when I get all records from SQLite. My blocks are this:

But when they are going to the remote server, I receive an error:


I know it is because something with the file path of the picture(s) but I don't know how to solve yet.

Any clues?

How are you saving the images in SQLite by filepath (so just a file path to the image), or as base64, or as blobs ?

And are you intending to save the images to MySQL as base64, or again as a link to an uploaded file (recommended)

Not sure why you are doing resize twice ?

He is using Base64 to store their images.

In fact, I was reducing and saving as base64 in SQlite, but I changed this way, so in SQLite I am saving by filepath. The blocks I showed is when I m taking all data from SQLite and preparing to send to MySQL database

Which Sqlite extension are you using ?

Yours

:smiley:
OK, let me see what I can do.

Just to check, your aim is to save the image as a base64 string in a mysql table field ?

Exactly. It because I need to be a fast way to save the images remotely.

There are two image fields. Both fields can receive images from camera or from gallery (We discussed about it in the other topic). And in SQLite they are stored this way:

Frist image (from camera):

Second image (from gallery):

The error comes out when I am sending those images to remote server.

I have only done an example for one image, but you should be able to replicate for a second image.

assumes your php file is setup to receive an imgName and base64String parameter.

If you have already got this far, and the problem is with the php, then we would need to look at that.

1 Like

Very interesting solution, @TIMAI2 . I'll try this way and tell you the results.

Thank you very much for your time and suggestion.

@TIMAI2 I just have a doubt: When i choose the camera to take a picture, the filepath comes like:

file:///storage/emulated/0/...........

And when I choose from gallery, the filepath comes like:

/storage/emulated/0/..........

And I am using this block in the two fields:

Maybe the error I am facing is because of this... or am I wrong?

What is the error?

It is in the first post

image

should be OK, possibly something else causing the error. Will be needed for the camera file path.

You would need to isolate where the error arises (debug)

You could also use just one instance o ImageConvertor for the resizing, just call the second resize from the event of the first (use a variable to define which one is being called, e.g. first, second)

1 Like

Ok, I did this for both fields:

And problem is solved! Thank you very much @TIMAI2

If there is no file://, nothing will be replaced.

1 Like

Hi @Anke , the way you showed was my first try. But the error (in the first post) came out and when I changed to this way, it worked.

Be aware that if you are using ImagePicker it only stores the last 10 files. Thus, if you are saving more than ten files to sqlite, the earliest ones will no longer exist. To overcome this see here:

If you are using FilePicker then this returns a contenturi which may not be readable by most extensions (because the contenturi needs to be converted to a file path).

My guess is that you perhaps needed to dig deeper with your debugging in order to check the file paths being returns and that the file actually exists.

1 Like

That doesn't make any sense at all. :woman_shrugging: :upside_down_face:

1 Like