• Hi there – I recently had a situation where the file contents returned by models/DspExportImportModel.php::urlGetContents() was causing an error (DSPMENUS_IMPORTMSG2 => “Uploaded file is either Empty or not a valid JSON file.”). Researching it, I discovered the contents being returned for the uploaded file were compressed (byte 0 was 0x1f and byte 1 was 0x8b). To fix this, just before returning the string in urlGetContents(), I added the following:

    
    if ( $url_get_contents_data !== false &&
         ord($url_get_contents_data[0]) == 0x1f && 
         ord($url_get_contents_data[1]) == 0x8b )
        $url_get_contents_data = gzinflate(substr($url_get_contents_data,10));
    
    

    This checks to see if the content is compressed (by looking at the first two bytes, then removing the 10byte header before running it through gzinflate().

    I haven’t tested this extensively but it did solve the issue I was having.

    • This topic was modified 3 years, 4 months ago by amatheson.
  • The topic ‘Dealing with compressed files’ is closed to new replies.