Extension. Unzip .zip file with subdirectories. Web local. Base64 to CloudDB. Source code

  • Using this extension we can:

  • Unzip a .zip file with subdirectories (recursively).

  • Convert a file in the application directory to String Base64.

  • Create a file in the application directory from a Base64 String.

  • Get the application directory.

  • Delete a directory and subdirectories. Delete file.

extension_unzip3

  • You can get the extension and its source code at:

http://kio4.com/appinventor/275B_extensiones_descomprimir.htm

7 Likes

1.- Unzip web.zip file in app directory. Web local.

p175B_extension_unzip_web.aia (670.6 KB)

On our PC we have created a structure of a website with .htm files and image subdirectory.
We compressed that structure into a web.zip (660 KB).
We upload it to the asset of our application.
We CopyFile the web.zip from the Asset to the Application directory.
We Unzip the web.zip file in the web subdirectory.
Through the WebViewer component we see the local website: App/web/index.htm

extension_unzip2

  • If you want to delete the App/web.zip file and the App/web directory with its subdirectories, you can use these codes...

extension_unzip10

  • DeleteDirectory block also deletes files, we can use it to delete the web.zip
1 Like

2.- Web in CloudDB. Store web.zip with Base64 in CloudDB. Get Base64 from CloudDB to a file in App. Unzip web2.zip. WebViewer.

p175B_extension_unzip_web_CloudDB.aia (671.2 KB)

1 Like

3.- Credits. Source code. Comments.

  • The code to Unzip .zip recursively (with subdirectories) is based on...

https://howtodoinjava.com/java/io/unzip-file-with-subdirectories/

  • Delete directories recursively.

https://stackoverflow.com/questions/73953530/delete-files-in-folder-recursively-in-java-i-o

  • The Source code of the extension can be obtained at...

http://kio4.com/appinventor/275B_extensiones_descomprimir.htm

  • We can also use Firebase instead of CloudDB.

  • Once the web.zip file has been unzipped in the app, we can delete it so that it does not take up space.

  • Instead of using the GetAsdPath block, we can use the MakeFullPath of the File component.

  • Structure of the web.zip file.

extension_unzip8

1 Like

1.for file name, what about set it's default directory as ASD, that means, if we write 'web.zip', or '/web.zip', it will save file to ASD, no need to join 'getAsdPath' block. You just need to check if the file name starts with '/storage/emulated/0/...'

  1. For Clouddb, it will convert a file to BASE64 and save it on line if you give the 'valueToStore' a full file path, no need to change to Base64 manually .

Shouldn't there be an .Unzipped event?

1 Like

But it should also be possible to save (unzip) directly to one of the Shared folders (/Documents or /Download). Of course without storage permissions on Android 11+.

... and if it's unzipped into the Shared folder /Documents, such files can later also be accessed with other apps using SAF. This would not be possible if only unzipping into the ASD.

of course it can save to shared folders.

if filename.startsWith('/storage/emulated/0/){
....}
else{
if (!filename.startsWith('/') ) {filename = '/' +filename }
filename =ASD + filename;
.....

}
1 Like

The files can always be copied/moved later to a "shared" folder, if that is what is required...

As I said:

... without using another component (File).

or :
file:///storage/...
or:
/sdcard
or:
file:///sdcard

For example:

but it should also work with an absolute path (but doesn't). @Taifun

The same applies to FileTools. @vknow360

@Juan_Antonio Sorry that we / I have expanded your topic a bit. But these questions/issues arose.
Maybe you or someone else should move the last posts to a new topic. :woman_shrugging: :thinking:

I prefer to use the absolute address.

Clouddb, it will convert a file to BASE64

I created the possibility of converting to Base64 to be able to upload the information to "another" cloud, such as FireBaseDB or a PHP code in a hosting.

The example is just an example.

1 Like

The example file is 660 KB in size and works perfectly and quickly in the tests performed.

It doesn't matter. :blush: :+1: