How to set a header for loading an .apk or .jar file?

I have an example file $ test.zip or test.apk or test.jar

$len = filesize($file); $filename = basename($file); ob_end_clean(); JResponse::clearHeaders(); JResponse::setHeader('Pragma', 'public', true); JResponse::setHeader('Expires', '0', true); JResponse::setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true); JResponse::setHeader('Content-Type', $file, true); JResponse::setHeader('Content-Disposition', 'attachment; filename='.$filename.';', true); JResponse::setHeader('Content-Transfer-Encoding', 'binary', true); JResponse::setHeader('Content-Length', $len, true); JResponse::sendHeaders(); echo JFile::read($file); 

When reading a file, since test.zip is the result of OK, but when read file test.apk or test.jar is a system error, how to set the header for reading this file (apk, jar)

+6
source share
2 answers

setHeader in Content-Type

 'apk' => 'application/vnd.android.package-archive' 'jar' => 'application/java-archive' 

More details: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types

+18
source

Try using

 Content-type: application/jar Content-type: application/apk 

But I think this line of code is wrong.

 JResponse::setHeader('Content-Type', $file, true); 

You should probably use this as

 JResponse::setHeader('Content-Type', 'application/jar', true); 
0
source

Source: https://habr.com/ru/post/921261/


All Articles