Howto open PDF files in same browser window?

Unfortunately, no. :roll_eyes:

1 Like

Hello, get the same problem.
PDF file does not display but always download , whatever config I have on my explorer (chrome, firefox)
From what I am reading this is related with content_type for the file
I have found this

Great question! What defines that action is the “Content-type” header sent from the server to the client. You can define the value of this header using s3-compatible tooling. There is a good explanation of this here:

But I haven’t been able to progress.
It seams the issue is indicate Content-Type or content-disposition but I don’t know if I have to do it at uploading,
Perhaps some expert can help us.

I found this information more clear than the previous one.
My problem is I don’t know how to use it to solve the situation. :sob:

If you want the browser to treat the file as pdf you should let him know that his file is a pdf. The way to do so is to send the relevant header:
Content-type: application/pdf

The current header that is sent by s3 is:
Contant-type: application/octet-stream

Since you upload the files to s3 - you can either set the correct mime-type for the file during uploading, or afterward using some of the s3 tools (like s3cmd for windows, for example).

According to the link to the documentation you provided, the putObjectFile function is deprecated, but this is the definition:
putObjectFile (string $file, string $bucket, string $uri, [constant $acl = S3::ACL_PRIVATE], [array $metaHeaders = array()], [string $contentType = null])

As you can see - the last parameter is contentType - so you can set it to application/pdf when uploading the file.
This will set the correct header when downloading