0

My media files lose all meta information when downloading. I have a website with downloadable, virtual products. It affects here Android app files, apk's.

If I want to download and install the files, I get the following error.

There was a problem parsing the package.

The Download package (apk) has not include version number, file size, package name. It shows only N/A .

Scenario:

  • I have downloaded apk file directly via ftp from the vmfiles file folder. Metadata available - installation ok.

  • Download Website - File does not include version number, file size, package name. Installation fails with the above message.

I work with:

  • VirtueMart 3.2.15 Blue Corvus 9877
  • Joomla 3.8.7
  • OpenTools Virtuemart Download for sale plugin

I switched the database to utf8mb4 because I need symbols in text and description. Since then, the downloaded products are probably not usable, I think.

I modified the varchar fields, varchar (191), or changed them to text. I just do not know why, how and where the package information is lost.

Here is another phpmyadmin mysql query of variables / collation:

SHOW VARIABLES LIKE 'char%'

--------------------
Web server productive:
-------------------------------------
variable_name value
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb4
character_set_filesystem binary
character_set_results utf8mb4
character_set_server utf8
character_set_system utf8
character_sets_dir / usr / share / mysql / charsets /

----------
Local Host:
-------------------------------------
Variable_name Value
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb4
character_set_filesystem binary
character_set_results utf8mb4
character_set_server utf8mb4
character_set_system utf8
character_sets_dir C: \ xampp \ mysql \ share \ charsets \

I had already purchased the software from OpenTools in February 2016. The Software is not more supported. Maybe I can reach someone in the forum or by email. As I said, the uploaded files on the server are still fine. And the download software reads the file stream via readfile_chunked byte by byte for the download link.

Maybe some base64 or something has to be encoded here? Or is the error somewhere else?

Android Studio says when opening the downloaded .apk file:

Unknown chunk type: 835 java.lang.NullPointerException: Unknown chunk type: 835

Virtuemart works with utf8, mysql supports Multi (utf8 + utf8mb4). My system is set up with utf8mb_unicode_ci.

Should I switch to connection encoding utf8mb4_bin? Does Virtuemart realize that? I will definitely try it now.

I found another code snippet regarding mysql_encoding:

utf8mb4 is missing here:

switch($mysql_encoding[0])
{
    case "utf8":
        return "utf-8";
        break;
    case "latin1":
        return "iso-8859-1";
        break;
    default:
        return $mysql_encoding[0];
}

Should such a thing be taken into the Virtuemart model with me? Somewhere I have read something from Java Binary Variables specifically for utf8mb4 call handling. That you have to set up this extra. Also, attaching '? UseUnicode = true & characterEncoding = UTF-8' to the JDBC URL download link did not help.

halfer
  • 19,824
  • 17
  • 99
  • 186
Michael
  • 11
  • 3
  • There are differences between original and downloaded file. For file downloaded from web page: AndroidManifest.xml will not open. No project code will be displayed. For the original file: AndroidManifest.xml opens, displays all information Various project source codes, meta info are also displayed. In the code of the download plugin, the output buffer is deleted in readfile_chunked: readfile_chunked($filename, $retbytes=true) ... while (!feof($handle)) { $buffer = fread($handle, $chunksize); echo $buffer; ob_flush(); flush(); – Michael May 24 '19 at 08:57

1 Answers1

1

A coding God in another forum could help me further and found the solution :-) In the used readfile_chunked querier, whether the output buffer is deleted here. The solution was to put ob_clean () before the while loop.

function readfile_chunked($filename, $retbytes=true)
{
    $ chunksize = 1 * (1024 * 1024); // how many bytes by chunk
    $ buffer = '';
    $ cnt = 0;
                    
    $ handle = fopen ($ filename, 'rb');

    if ($ handle === false) 
    {
       return false;
    }
    ob_clean ();

    while (! feof ($ handle)) 
    {
       $ buffer = fread ($ handle, $ chunksize);
       echo $ buffer;
       ob_flush ();
       flush ();
                           
       if ($ retbytes) 
       {
          $ cnt + = strlen ($ buffer);
       }
    }                  
    $ status = fclose ($ handle);

    if ($ retbytes && $ status) 
    {
       return $ cnt; // return num. bytes delivered like readfile () does.
    }                   
    return $ status;
}
Michael
  • 11
  • 3
  • This looks pretty good, but it will be clearer (both in your own code and here) if it is indented correctly. – halfer May 24 '19 at 20:26
  • 1
    Hello halfer. Yes, there you are right, readable code for all other developers, because you really should pay attention. I have better engaged him now. Some say it's a waste of lines, but for me it's easier to read for a quicker overview. That is not so exhausting. – Michael May 28 '19 at 13:30