@@ -34,7 +34,7 @@ const parseS3Url = (s3Url) => {
3434 return { bucket, key } ;
3535} ;
3636
37- const generateS3PresignedUrl = async ( url , credentials ) => {
37+ const generateS3PresignedUrl = async ( url , credentials , options = { } ) => {
3838 // If it's already a special URL (like detailType), return as is
3939 if ( url . includes ( 'detailType' ) ) {
4040 return url ;
@@ -72,7 +72,24 @@ const generateS3PresignedUrl = async (url, credentials) => {
7272
7373 // Parse the URL for the presigner
7474 const s3ObjectUrl = parseUrl ( newUrl ) ;
75+
76+ // Determine file type from key to set appropriate content disposition
77+ const fileExtension = key . split ( '.' ) . pop ( ) . toLowerCase ( ) ;
78+ const isDisplayableFile = [ 'pdf' , 'jpg' , 'jpeg' , 'png' , 'gif' , 'svg' , 'webp' ] . includes ( fileExtension ) ;
79+
80+ // Add query parameters for inline display if it's a displayable file type
81+ if ( isDisplayableFile && options . forceInline !== false ) {
82+ s3ObjectUrl . query = s3ObjectUrl . query || { } ;
83+ s3ObjectUrl . query [ 'response-content-disposition' ] = 'inline' ;
84+
85+ // Set appropriate content type for PDFs to ensure proper display
86+ if ( fileExtension === 'pdf' ) {
87+ s3ObjectUrl . query [ 'response-content-type' ] = 'application/pdf' ;
88+ }
89+ }
90+
7591 logger . debug ( 'Canonical URL:' , newUrl ) ;
92+ logger . debug ( 'Query parameters:' , s3ObjectUrl . query ) ;
7693
7794 // Create presigner instance
7895 const presigner = new S3RequestPresigner ( {
0 commit comments