Dusting off those HIVE muscle memories

in #programming2 years ago (edited)

A contest entry followed by a couple of posts and what do you know, the old coding vibes are beginning to percolate to the surface once again. My last programming interest on HIVE was my exploration into base64 encoding and how that might be used to post images directly to the blockchain as opposed to AWS cloud servers as they are at present.

Python was my first choice of programming languages, yet my familiarity with the language is not very robust; so after some hitting of my head against the proverbial wall eventually my old tried and true language of Perl was used.

The first step was to take the image blunt.jpg and convert it to base64 encoding and then display that on a web page. Kind of a proof of concept.

blunt.jpg

  • blunt.jpg

It was decided to make the form entry page dynamic and generated from the script in question. This moved ahead well and soon there was a page being generated to test the encoding through.

image.png

The actual conversion took a bit longer yet finally that old dopamine rush was felt after about the 7th or 8th attempt.

image.png

With great suspense a jump was made to the terminal to place the base64 output into a text file and then run the command:

$base64 -d output.txt > blunt.jpg

Low and behold it was returned to graphics mode in all its glory.

blunt.jpg

The next step will be to have the base64 output posted to the blockchain instead of to the browser like this old test post. That's going to take some thought so as to make this a welcome utility and not an annoyance on the feeds. Perhaps a little community of its own would achieve that result.

The mods could be endless at that point. For example offering a means to sort through the images using tags. Maybe a dApp could be on the horizon.

More to come as more progress is made...


Peace Out

Sort:  

@novacadian I did a bunch of R&D work with storing files on chain. The simplest way that I found to reconstruct the file is to have it be decoded and passed to the browser as a blob URL. You can dig through my other repositories that deal with on chain storage but the following is a good example: https://github.com/txtatech/hive-fc-linux

A sweet tip, @jacobpeacock! Thanks.

You are quite welcome! That gzip plus base64 combo that I use is pretty slick also. It definitely helps keep the base64 strings smaller.

Any saving of resources is helpful. Base64 does not compress very well and image files like jpg are already compressed, so the savings are not as substantial as other data for those reasons.

If memory serves it gzips whatever file it is and then base64 encodes the gzipped data. I did not tinker with image files but it did alright with other media files. I get what you mean though.

The last thing that I was working on was this: https://github.com/txtatech/qr-weaver which takes an input file and turns it into an animated gif of QR codes that can be decoded back to the original file.

Now that would be cool to be able offer QR codes that could summon an image from the blockchain. You have my wheels spinnin'. :)

They can store entire files as an animated gif. I have another project that also makes QR code videos for storing entire files. Pretty neat stuff really.

EDIT: Oh I forgot that qr-weaver project has the video creation in it as well.

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

Appreciate the support!


Hey @novacadian, here is a little bit of BEER from @fjworld for you. Enjoy it!

We love your support by voting @detlev.witness on HIVE .

Isn'it by far too much data for the blockchain/blocksize?

My thoughts exactly and for that reason the idea was put on the back burner since 2020. However it seems that HIVE sharding may be on the way. Will keep it limited beta until some form of sharding is available.