News:

Support the VirtueMart project and become a member

Main Menu

Media files lose all meta information when downloading

Started by Micha70, May 24, 2019, 01:10:06 AM

Previous topic - Next topic

Micha70

Hello everybody,

I have a serious problem.

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.


- Download 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.



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 hope someone can help me.

greetings

Studio 42

Check your downloaded file, if you dont have a error message included at the begin or end of file generated by PHP.(notepad++ or directly windows commander can display binaries files for eg.)
In this case the file is not valid

Jörgen

Please do not double post. This is a subject for the open tools developers.
Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

StefanSTS

Unfortunately Open Tools is kind of closed down and is not giving support anymore.

All software is offered for free now, so you might use the software, but you have to take care of it yourself.

Regards
Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

Micha70

Sorry, yes, because of the double post have noted. Had such a feeling under migration wrong to have posted.

I had already purchased the software from OpenTools in February 2016. 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.
I think that blows up everything here the frame * Hands over head *

Studio 42

@Micha70, if you binary compare the 2 files(original and donwloaded) do you have no diff ?
Sometime a system plugin can send additional code as a linebreak or space. If the output buffer is not cleared, then you can have an error.

Micha70

Yes, that's right. There are definitely differences between the original and the downloaded file.

For file downloaded from web page:
AndroidManifest.xml will not open.
No project source 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();

Studio 42

Add a
ob_clean();
before the loop
while (!feof($handle)) {
So you are sure the buffer is full empty.

Micha70

Studio, you are so amazing!  :-*
That's exactly what it was. It works. Phenomenal!
I'm just jumping for joy in the circle.

Many many thanks to you..coding god  ;)


That's now the function:
function readfile_chunked($filename, $retbytes=true) {
      $chunksize = 1*(1024*1024); // how many bytes per 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 $status;
   }

Many greetings