Android Question mysql large text n video files to download

GudEvil

Member
Licensed User
Longtime User
mytask is to download large text file(content) and video file from mysql server.

as text file would be around couple pages "text" or "varchar" in mysql
video file should be around 5mb max.

my issue is how to get those download or see in android?

I tried download large file with persistent link but it is not in my case
https://www.b4x.com/android/forum/threads/download-huge-files-with-httputils2.30220/

as i can able to retrieve other mysql content remotelly using http2utils.
I am using httpjob.poststring(,) can httpjob.download2(,) has advantages
 

DonManfred

Expert
Licensed User
Longtime User
as i can able to retrieve other mysql content remotelly using http2utils.
You are calling a php which give the results back to your app?
Then you could read the field in php, base64encode the data and give the resulting base64 string back to the app. In b4a you decode the base64string and get the data which you then can save locally on your device to read and show them
 
Upvote 0

GudEvil

Member
Licensed User
Longtime User
yes calling php.

i tried that for image which works perfectly fine, but what abt text n video.

once I decode in app, how do i convert it to text or video..

B4X:
                Dim srt_util As StringUtils
                    Dim b() As Byte = srt_util.DecodeBase64(m.Get("content"))
                    Dim In As InputStream
                    In.InitializeFromBytesArray(b,0,b.Length)
                    Bitmap1.Initialize2(In)

this is what i used for image, which works fines, but how do i convert that input stream back to text and video???


thanks for reply though
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
But, honestly said it is not a good practive to store big data in a database. At least on the android device(s) you will run OOM when trying to decode a huge base64 string.
Maybe your php runs OOM earlier when creating a huge base64

It is most probably better to store the filename and or path in the db an access the files static (downloading with httputils first, then showing) than to store them in the Database if they are NOT Text. Images, Documents of any type, Videos.
 
Upvote 0

GudEvil

Member
Licensed User
Longtime User
how do i read text/video from that input stream...


your suggestion would be I store video somewhere in static location then use that link to download files??
how to I do it??
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
how do i read text/video from that input stream...
How do you write the image to an imagefile as you said it is working fine for images?

Do the same for video, text, whatever and save it to a file like you did it with the image...
 
Upvote 0

GudEvil

Member
Licensed User
Longtime User
i will try that...

In.InitializeFromBytesArray(b,0,b.Length)
Bitmap1.Initialize2(In)

this is for images..

is
In.InitializeFromBytesArray(b,0,b.Length)
text.readfrom(in)

something similr ?? correct...

many maany thanks...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
something like

B4X:
Dim b() As Byte = srt_util.DecodeBase64(m.Get("content"))
Dim In As InputStream
In.InitializeFromBytesArray(b,0,b.Length)
Dim OutStream As OutputStream
OutStream = File.OpenOutput(File.DirRootExternal, "filename.ext", False)
File.Copy2(in,OutStream) ' save the file where in is the filled inputstream
OutStream.Close
 
Upvote 0

GudEvil

Member
Licensed User
Longtime User
looks good, will try fro video file too...

also how do i handle escape character retrieved from jason... It has three paragrah text. I can retrieve smoothly but with few escape chars...

is it possible I save this string in new pdf file??
 
Upvote 0
Top