AWS S3: Force File Download using 'response-content-disposition'

    String codedFilename=  EncodingUtil.urlEncode(bucketPath,'UTF-8');

    String stringtosign = 'GET\n\n\n'+Lexpires+'\n/'+bucketName+'/'+codedFilename+'?response-content-disposition=attachment; filename=abc.doc';

    String signed = make_sig(stringtosign); 

    String codedsigned = EncodingUtil.urlEncode(signed,'UTF-8');

    String url = serverURL+'/'+bucketName+'/'+codedFilename+'?response-content-disposition='+EncodingUtil.urlEncode('attachment; filename=abc.doc','UTF-8')+'&AWSAccessKeyId='+awskey+'&Expires='+Lexpires+'&Signature='+codedsigned;

Source: Unable to override content disposition header in s3

Chrome has problem if content type is 'application/octet-stream' for a document(pdf int this case). However chrome is OK if content type is 'binary/octet-stream'.

Thankfully S3 defaults Content-Type of download to 'binary/Octet-stream' if nothig is set at the time of upload.

My Advice:- If one needs to files of 'any' type to S3 without knowing content type at the time of upload, simply do not set it or set it to 'binary/Octet-stream'. This way Chrome will show warning but file is downloaded.